Add ossl_encode symbols
authorShane Lontis <shane.lontis@oracle.com>
Mon, 8 Mar 2021 23:59:13 +0000 (09:59 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Thu, 18 Mar 2021 07:52:37 +0000 (17:52 +1000)
Partial fix for #12964

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14473)

crypto/asn1_dsa.c
crypto/dsa/dsa_sign.c
crypto/ec/ec_asn1.c
include/crypto/asn1_dsa.h
providers/common/der/der_sm2.h.in
providers/common/der/der_sm2_key.c
providers/common/der/der_sm2_sig.c
providers/implementations/signature/sm2sig.c

index cb48ae9956ec1191d63f52c6e5a51c19915e8008..59642f4b3ca61996a3d27acf00c0ef6883a04136 100644 (file)
@@ -36,7 +36,7 @@
  *
  * Returns 1 on success or 0 on error.
  */
-int encode_der_length(WPACKET *pkt, size_t cont_len)
+int ossl_encode_der_length(WPACKET *pkt, size_t cont_len)
 {
     if (cont_len > 0xffff)
         return 0; /* Too large for supported length encodings */
@@ -63,7 +63,7 @@ int encode_der_length(WPACKET *pkt, size_t cont_len)
  *
  * Returns 1 on success or 0 on error.
  */
-int encode_der_integer(WPACKET *pkt, const BIGNUM *n)
+int ossl_encode_der_integer(WPACKET *pkt, const BIGNUM *n)
 {
     unsigned char *bnbytes;
     size_t cont_len;
@@ -84,7 +84,7 @@ int encode_der_integer(WPACKET *pkt, const BIGNUM *n)
 
     if (!WPACKET_start_sub_packet(pkt)
             || !WPACKET_put_bytes_u8(pkt, ID_INTEGER)
-            || !encode_der_length(pkt, cont_len)
+            || !ossl_encode_der_length(pkt, cont_len)
             || !WPACKET_allocate_bytes(pkt, cont_len, &bnbytes)
             || !WPACKET_close(pkt))
         return 0;
@@ -103,7 +103,7 @@ int encode_der_integer(WPACKET *pkt, const BIGNUM *n)
  *
  * Returns 1 on success or 0 on error.
  */
-int encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s)
+int ossl_encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s)
 {
     WPACKET tmppkt, *dummypkt;
     size_t cont_len;
@@ -122,8 +122,8 @@ int encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s)
     }
 
     /* Calculate the content length */
-    if (!encode_der_integer(dummypkt, r)
-            || !encode_der_integer(dummypkt, s)
+    if (!ossl_encode_der_integer(dummypkt, r)
+            || !ossl_encode_der_integer(dummypkt, s)
             || !WPACKET_get_length(dummypkt, &cont_len)
             || (!isnull && !WPACKET_finish(dummypkt))) {
         if (!isnull)
@@ -133,13 +133,13 @@ int encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s)
 
     /* Add the tag and length bytes */
     if (!WPACKET_put_bytes_u8(pkt, ID_SEQUENCE)
-            || !encode_der_length(pkt, cont_len)
+            || !ossl_encode_der_length(pkt, cont_len)
                /*
                 * Really encode the integers. We already wrote to the main pkt
                 * if it had a NULL buffer, so don't do it again
                 */
-            || (!isnull && !encode_der_integer(pkt, r))
-            || (!isnull && !encode_der_integer(pkt, s))
+            || (!isnull && !ossl_encode_der_integer(pkt, r))
+            || (!isnull && !ossl_encode_der_integer(pkt, s))
             || !WPACKET_close(pkt))
         return 0;
 
@@ -250,4 +250,3 @@ size_t ossl_decode_der_dsa_sig(BIGNUM *r, BIGNUM *s,
     *ppin += consumed;
     return consumed;
 }
-
index 6819e5c1317edd3b85984294eeed02919604c923..6e87bd16571902d9a2f54f537ef0cdbc8b7498e7 100644 (file)
@@ -95,7 +95,7 @@ int i2d_DSA_SIG(const DSA_SIG *sig, unsigned char **ppout)
             return -1;
     }
 
-    if (!encode_der_dsa_sig(&pkt, sig->r, sig->s)
+    if (!ossl_encode_der_dsa_sig(&pkt, sig->r, sig->s)
             || !WPACKET_get_total_written(&pkt, &encoded_len)
             || !WPACKET_finish(&pkt)) {
         BUF_MEM_free(buf);
index 03c65ee403fa81cba46b01d07bc7e7c9049e895e..ed30d1b3a90d709c4ae4d0ddf3f651940c06f1b5 100644 (file)
@@ -1245,7 +1245,7 @@ int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **ppout)
             return -1;
     }
 
-    if (!encode_der_dsa_sig(&pkt, sig->r, sig->s)
+    if (!ossl_encode_der_dsa_sig(&pkt, sig->r, sig->s)
             || !WPACKET_get_total_written(&pkt, &encoded_len)
             || !WPACKET_finish(&pkt)) {
         BUF_MEM_free(buf);
index 2657dae0f442697eabe36f2faf2e1c4a0c6eb292..3eadb9ec3c545165a41eb32334f3a7953d914c81 100644 (file)
@@ -13,9 +13,9 @@
 
 #include "internal/packet.h"
 
-int encode_der_length(WPACKET *pkt, size_t cont_len);
-int encode_der_integer(WPACKET *pkt, const BIGNUM *n);
-int encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s);
+int ossl_encode_der_length(WPACKET *pkt, size_t cont_len);
+int ossl_encode_der_integer(WPACKET *pkt, const BIGNUM *n);
+int ossl_encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s);
 int ossl_decode_der_length(PACKET *pkt, PACKET *subpkt);
 int ossl_decode_der_integer(PACKET *pkt, BIGNUM *n);
 size_t ossl_decode_der_dsa_sig(BIGNUM *r, BIGNUM *s, const unsigned char **ppin,
index 1cc330fcea7c99b6c609c77ac29bffd9673204f0..fe21095e59d0f82b1ef387affe09efa3b6a3370d 100644 (file)
@@ -18,7 +18,7 @@
 -}
 
 /* Subject Public Key Info */
-int DER_w_algorithmIdentifier_SM2(WPACKET *pkt, int cont, EC_KEY *ec);
+int ossl_DER_w_algorithmIdentifier_SM2(WPACKET *pkt, int cont, EC_KEY *ec);
 /* Signature */
-int DER_w_algorithmIdentifier_SM2_with_MD(WPACKET *pkt, int cont,
-                                          EC_KEY *ec, int mdnid);
+int ossl_DER_w_algorithmIdentifier_SM2_with_MD(WPACKET *pkt, int cont,
+                                               EC_KEY *ec, int mdnid);
index a766bb4f3dd7e2cc3c855e6ae7d4dc9e9ba6bfaa..5889f2ba0e72603b652de057dd699118d4152cb1 100644 (file)
@@ -12,7 +12,7 @@
 #include "prov/der_ec.h"
 #include "prov/der_sm2.h"
 
-int DER_w_algorithmIdentifier_SM2(WPACKET *pkt, int cont, EC_KEY *ec)
+int ossl_DER_w_algorithmIdentifier_SM2(WPACKET *pkt, int cont, EC_KEY *ec)
 {
     return ossl_DER_w_begin_sequence(pkt, cont)
         /* No parameters (yet?) */
index 7b710cfa53fb76042a98c3e078ed432a1ea9a4d0..1e904bb5cd4703ea26b1f8bad9b00718315a5caa 100644 (file)
@@ -20,8 +20,8 @@
         precompiled_sz = sizeof(ossl_der_oid_id_sm2_with_##name);       \
         break;
 
-int DER_w_algorithmIdentifier_SM2_with_MD(WPACKET *pkt, int cont,
-                                          EC_KEY *ec, int mdnid)
+int ossl_DER_w_algorithmIdentifier_SM2_with_MD(WPACKET *pkt, int cont,
+                                               EC_KEY *ec, int mdnid)
 {
     const unsigned char *precompiled = NULL;
     size_t precompiled_sz = 0;
index 4201e825b134be684406bf25b80021c6802f7507..6fb0ff919b1ea41f8b90505dc52ec5f1b13dde02 100644 (file)
@@ -201,7 +201,7 @@ static int sm2sig_digest_signverify_init(void *vpsm2ctx, const char *mdname,
      */
     ctx->aid_len = 0;
     if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf))
-        && DER_w_algorithmIdentifier_SM2_with_MD(&pkt, -1, ctx->ec, md_nid)
+        && ossl_DER_w_algorithmIdentifier_SM2_with_MD(&pkt, -1, ctx->ec, md_nid)
         && WPACKET_finish(&pkt)) {
         WPACKET_get_total_written(&pkt, &ctx->aid_len);
         ctx->aid = WPACKET_get_curr(&pkt);