]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
der_writer: Use uint32_t instead of long.
authorDaniel Fiala <daniel@openssl.org>
Mon, 20 Jun 2022 16:40:30 +0000 (18:40 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 27 Jun 2022 08:58:40 +0000 (10:58 +0200)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18615)

crypto/der_writer.c
doc/internal/man3/ossl_DER_w_bn.pod
doc/internal/man7/DERlib.pod
include/internal/der.h
providers/common/der/der_rsa_key.c

index c6fd4c4298f6e5b43f0e1343d6ec1e3e9c7657e2..bd330785f90318f9fe7233aca8a254e53550a693 100644 (file)
@@ -106,11 +106,11 @@ static int int_der_w_integer(WPACKET *pkt, int tag,
         && int_end_context(pkt, tag);
 }
 
-static int int_put_bytes_ulong(WPACKET *pkt, const void *v,
+static int int_put_bytes_uint32(WPACKET *pkt, const void *v,
                                unsigned int *top_byte)
 {
-    const unsigned long *value = v;
-    unsigned long tmp = *value;
+    const uint32_t *value = v;
+    uint32_t tmp = *value;
     size_t n = 0;
 
     while (tmp != 0) {
@@ -125,9 +125,9 @@ static int int_put_bytes_ulong(WPACKET *pkt, const void *v,
 }
 
 /* For integers, we only support unsigned values for now */
-int ossl_DER_w_ulong(WPACKET *pkt, int tag, unsigned long v)
+int ossl_DER_w_uint32(WPACKET *pkt, int tag, uint32_t v)
 {
-    return int_der_w_integer(pkt, tag, int_put_bytes_ulong, &v);
+    return int_der_w_integer(pkt, tag, int_put_bytes_uint32, &v);
 }
 
 static int int_put_bytes_bn(WPACKET *pkt, const void *v,
@@ -153,7 +153,7 @@ int ossl_DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v)
     if (v == NULL || BN_is_negative(v))
         return 0;
     if (BN_is_zero(v))
-        return ossl_DER_w_ulong(pkt, tag, 0);
+        return ossl_DER_w_uint32(pkt, tag, 0);
 
     return int_der_w_integer(pkt, tag, int_put_bytes_bn, v);
 }
index a5bdd848bfadf30fadbf73ef4b214ff7217432d9..3d67067a9e8bf8c65bf789faadee345a094ebcb2 100644 (file)
@@ -2,7 +2,7 @@
 
 =head1 NAME
 
-ossl_DER_w_boolean, ossl_DER_w_ulong, ossl_DER_w_bn, ossl_DER_w_null,
+ossl_DER_w_boolean, ossl_DER_w_uint32, ossl_DER_w_bn, ossl_DER_w_null,
 ossl_DER_w_octet_string, ossl_DER_w_octet_string_uint32
 - internal DER writers for DER primitives
 
@@ -11,7 +11,7 @@ ossl_DER_w_octet_string, ossl_DER_w_octet_string_uint32
  #include "internal/der.h"
 
  int ossl_DER_w_boolean(WPACKET *pkt, int tag, int b);
- int ossl_DER_w_ulong(WPACKET *pkt, int tag, unsigned long v);
+ int ossl_DER_w_uint32(WPACKET *pkt, int tag, uint32_t v);
  int ossl_DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v);
  int ossl_DER_w_null(WPACKET *pkt, int tag);
  int ossl_DER_w_octet_string(WPACKET *pkt, int tag,
@@ -29,7 +29,7 @@ ossl_DER_w_boolean() writes the primitive BOOLEAN using the value I<b>.
 Any value that evaluates as true will render a B<true> BOOLEAN,
 otherwise a B<false> BOOLEAN.
 
-ossl_DER_w_ulong() and ossl_DER_w_bn() both write the primitive INTEGER using
+ossl_DER_w_uint32() and ossl_DER_w_bn() both write the primitive INTEGER using
 the value I<v>.
 
 =for comment Other similar functions for diverse C integers should be
index 3129a9b74dc233b1407da669dba6eaac6f5902b1..f4f3abab51a415393d0c62f6e9a296f6d3debeaf 100644 (file)
@@ -118,7 +118,7 @@ value:
     {
         return ossl_DER_w_begin_sequence(pkt, tag)
             && (ossl_DER_w_begin_sequence(pkt, DER_NO_CONTEXT)
-                && ossl_DER_w_ulong(pkt, 2, 20)
+                && ossl_DER_w_uint32(pkt, 2, 20)
                 && ossl_DER_w_precompiled(pkt, 1,
                                           der_mgf1SHA256Identifier,
                                           sizeof(der_mgf1SHA256Identifier))
index 86b0d936e0d18af237b1223463db2668d7dbf764..8d6db8f066251d4cb982d77541de51b5c65734eb 100644 (file)
@@ -78,7 +78,7 @@ int ossl_DER_w_precompiled(WPACKET *pkt, int tag,
                            size_t precompiled_n);
 
 int ossl_DER_w_boolean(WPACKET *pkt, int tag, int b);
-int ossl_DER_w_ulong(WPACKET *pkt, int tag, unsigned long v);
+int ossl_DER_w_uint32(WPACKET *pkt, int tag, uint32_t v);
 int ossl_DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v);
 int ossl_DER_w_null(WPACKET *pkt, int tag);
 int ossl_DER_w_octet_string(WPACKET *pkt, int tag,
index e1c078b9060f48a148f853c7be3d4402fd7f13f5..4bad32ee6d6f7546c609153fa6826fc7d0bbea6e 100644 (file)
@@ -347,8 +347,8 @@ int ossl_DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag,
 
     return ossl_DER_w_begin_sequence(pkt, tag)
         && (trailerfield == default_trailerfield
-            || ossl_DER_w_ulong(pkt, 3, trailerfield))
-        && (saltlen == default_saltlen || ossl_DER_w_ulong(pkt, 2, saltlen))
+            || ossl_DER_w_uint32(pkt, 3, trailerfield))
+        && (saltlen == default_saltlen || ossl_DER_w_uint32(pkt, 2, saltlen))
         && DER_w_MaskGenAlgorithm(pkt, 1, pss)
         && (hashalg_nid == default_hashalg_nid
             || ossl_DER_w_precompiled(pkt, 0, hashalg, hashalg_sz))