rsa: add ossl_ prefix to internal rsa_ calls.
[openssl.git] / providers / common / der / der_rsa_key.c
index bd2de4a6c398f13eaaa856dfc4026da55b16a8a4..a20c334b2365df24d611d0e6a58029e4d060a01a 100644 (file)
@@ -64,66 +64,66 @@ const unsigned char der_aid_sha1Identifier[] = {
         DER_OID_SZ_id_sha224 + DER_SZ_NULL,                             \
         DER_OID_V_id_sha224,                                            \
         DER_V_NULL
-extern const unsigned char der_aid_sha224Identifier[];
-const unsigned char der_aid_sha224Identifier[] = {
+extern const unsigned char ossl_der_aid_sha224Identifier[];
+const unsigned char ossl_der_aid_sha224Identifier[] = {
     DER_AID_V_sha224Identifier
 };
-#define DER_AID_SZ_sha224Identifier sizeof(der_aid_sha224Identifier)
+#define DER_AID_SZ_sha224Identifier sizeof(ossl_der_aid_sha224Identifier)
 
 #define DER_AID_V_sha256Identifier                                      \
     DER_P_SEQUENCE|DER_F_CONSTRUCTED,                                   \
         DER_OID_SZ_id_sha256 + DER_SZ_NULL,                             \
         DER_OID_V_id_sha256,                                            \
         DER_V_NULL
-extern const unsigned char der_aid_sha256Identifier[];
-const unsigned char der_aid_sha256Identifier[] = {
+extern const unsigned char ossl_der_aid_sha256Identifier[];
+const unsigned char ossl_der_aid_sha256Identifier[] = {
     DER_AID_V_sha256Identifier
 };
-#define DER_AID_SZ_sha256Identifier sizeof(der_aid_sha256Identifier)
+#define DER_AID_SZ_sha256Identifier sizeof(ossl_der_aid_sha256Identifier)
 
 #define DER_AID_V_sha384Identifier                                      \
     DER_P_SEQUENCE|DER_F_CONSTRUCTED,                                   \
         DER_OID_SZ_id_sha384 + DER_SZ_NULL,                             \
         DER_OID_V_id_sha384,                                            \
         DER_V_NULL
-extern const unsigned char der_aid_sha384Identifier[];
-const unsigned char der_aid_sha384Identifier[] = {
+extern const unsigned char ossl_der_aid_sha384Identifier[];
+const unsigned char ossl_der_aid_sha384Identifier[] = {
     DER_AID_V_sha384Identifier
 };
-#define DER_AID_SZ_sha384Identifier sizeof(der_aid_sha384Identifier)
+#define DER_AID_SZ_sha384Identifier sizeof(ossl_der_aid_sha384Identifier)
 
 #define DER_AID_V_sha512Identifier                                      \
     DER_P_SEQUENCE|DER_F_CONSTRUCTED,                                   \
         DER_OID_SZ_id_sha512 + DER_SZ_NULL,                             \
         DER_OID_V_id_sha512,                                            \
         DER_V_NULL
-extern const unsigned char der_aid_sha512Identifier[];
-const unsigned char der_aid_sha512Identifier[] = {
+extern const unsigned char ossl_der_aid_sha512Identifier[];
+const unsigned char ossl_der_aid_sha512Identifier[] = {
     DER_AID_V_sha512Identifier
 };
-#define DER_AID_SZ_sha512Identifier sizeof(der_aid_sha512Identifier)
+#define DER_AID_SZ_sha512Identifier sizeof(ossl_der_aid_sha512Identifier)
 
 #define DER_AID_V_sha512_224Identifier                                  \
     DER_P_SEQUENCE|DER_F_CONSTRUCTED,                                   \
         DER_OID_SZ_id_sha512_224 + DER_SZ_NULL,                         \
         DER_OID_V_id_sha512_224,                                        \
         DER_V_NULL
-extern const unsigned char der_aid_sha512_224Identifier[];
-const unsigned char der_aid_sha512_224Identifier[] = {
+extern const unsigned char ossl_der_aid_sha512_224Identifier[];
+const unsigned char ossl_der_aid_sha512_224Identifier[] = {
     DER_AID_V_sha512_224Identifier
 };
-#define DER_AID_SZ_sha512_224Identifier sizeof(der_aid_sha512_224Identifier)
+#define DER_AID_SZ_sha512_224Identifier sizeof(ossl_der_aid_sha512_224Identifier)
 
 #define DER_AID_V_sha512_256Identifier                                  \
     DER_P_SEQUENCE|DER_F_CONSTRUCTED,                                   \
         DER_OID_SZ_id_sha512_256 + DER_SZ_NULL,                         \
         DER_OID_V_id_sha512_256,                                        \
         DER_V_NULL
-extern const unsigned char der_aid_sha512_256Identifier[];
-const unsigned char der_aid_sha512_256Identifier[] = {
+extern const unsigned char ossl_der_aid_sha512_256Identifier[];
+const unsigned char ossl_der_aid_sha512_256Identifier[] = {
     DER_AID_V_sha512_256Identifier
 };
-#define DER_AID_SZ_sha512_256Identifier sizeof(der_aid_sha512_256Identifier)
+#define DER_AID_SZ_sha512_256Identifier sizeof(ossl_der_aid_sha512_256Identifier)
 
 /*-
  * From https://tools.ietf.org/html/rfc8017#appendix-A.2.1
@@ -242,8 +242,8 @@ static const unsigned char der_aid_mgf1SHA512_256Identifier[] = {
 static int DER_w_MaskGenAlgorithm(WPACKET *pkt, int tag,
                                   const RSA_PSS_PARAMS_30 *pss)
 {
-    if (pss != NULL && rsa_pss_params_30_maskgenalg(pss) == NID_mgf1) {
-        int maskgenhashalg_nid = rsa_pss_params_30_maskgenhashalg(pss);
+    if (pss != NULL && ossl_rsa_pss_params_30_maskgenalg(pss) == NID_mgf1) {
+        int maskgenhashalg_nid = ossl_rsa_pss_params_30_maskgenhashalg(pss);
         const unsigned char *maskgenalg = NULL;
         size_t maskgenalg_sz = 0;
 
@@ -264,18 +264,19 @@ static int DER_w_MaskGenAlgorithm(WPACKET *pkt, int tag,
         if (maskgenalg == NULL)
             return 1;
 
-        return DER_w_precompiled(pkt, tag, maskgenalg, maskgenalg_sz);
+        return ossl_DER_w_precompiled(pkt, tag, maskgenalg, maskgenalg_sz);
     }
     return 0;
 }
 
 #define OAEP_PSS_MD_CASE(name, var)                                     \
     case NID_##name:                                                    \
-        var = der_oid_id_##name;                                        \
-        var##_sz = sizeof(der_oid_id_##name);                           \
+        var = ossl_der_oid_id_##name;                                   \
+        var##_sz = sizeof(ossl_der_oid_id_##name);                      \
         break;
 
-int DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag, const RSA_PSS_PARAMS_30 *pss)
+int ossl_DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag,
+                                 const RSA_PSS_PARAMS_30 *pss)
 {
     int hashalg_nid, default_hashalg_nid;
     int saltlen, default_saltlen;
@@ -291,17 +292,18 @@ int DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag, const RSA_PSS_PARAMS_30 *pss)
      * intent.  Therefore, we assert that here, the PSS parameters must show
      * that the key is restricted.
      */
-    if (!ossl_assert(pss != NULL && !rsa_pss_params_30_is_unrestricted(pss)))
+    if (!ossl_assert(pss != NULL
+                     && !ossl_rsa_pss_params_30_is_unrestricted(pss)))
         return 0;
 
-    hashalg_nid = rsa_pss_params_30_hashalg(pss);
-    saltlen = rsa_pss_params_30_saltlen(pss);
-    trailerfield = rsa_pss_params_30_trailerfield(pss);
+    hashalg_nid = ossl_rsa_pss_params_30_hashalg(pss);
+    saltlen = ossl_rsa_pss_params_30_saltlen(pss);
+    trailerfield = ossl_rsa_pss_params_30_trailerfield(pss);
 
     /* Getting default values */
-    default_hashalg_nid = rsa_pss_params_30_hashalg(NULL);
-    default_saltlen = rsa_pss_params_30_saltlen(NULL);
-    default_trailerfield = rsa_pss_params_30_trailerfield(NULL);
+    default_hashalg_nid = ossl_rsa_pss_params_30_hashalg(NULL);
+    default_saltlen = ossl_rsa_pss_params_30_saltlen(NULL);
+    default_trailerfield = ossl_rsa_pss_params_30_trailerfield(NULL);
 
     /*
      * From https://tools.ietf.org/html/rfc8017#appendix-A.2.1:
@@ -329,31 +331,31 @@ int DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag, const RSA_PSS_PARAMS_30 *pss)
         return 0;
     }
 
-    return DER_w_begin_sequence(pkt, tag)
+    return ossl_DER_w_begin_sequence(pkt, tag)
         && (trailerfield == default_trailerfield
-            || DER_w_ulong(pkt, 3, trailerfield))
-        && (saltlen == default_saltlen || DER_w_ulong(pkt, 2, saltlen))
+            || ossl_DER_w_ulong(pkt, 3, trailerfield))
+        && (saltlen == default_saltlen || ossl_DER_w_ulong(pkt, 2, saltlen))
         && DER_w_MaskGenAlgorithm(pkt, 1, pss)
         && (hashalg_nid == default_hashalg_nid
-            || DER_w_precompiled(pkt, 0, hashalg, hashalg_sz))
-        && DER_w_end_sequence(pkt, tag);
+            || ossl_DER_w_precompiled(pkt, 0, hashalg, hashalg_sz))
+        && ossl_DER_w_end_sequence(pkt, tag);
 }
 
 /* Aliases so we can have a uniform RSA_CASE */
-#define der_oid_rsassaPss der_oid_id_RSASSA_PSS
+#define ossl_der_oid_rsassaPss ossl_der_oid_id_RSASSA_PSS
 
 #define RSA_CASE(name, var)                                             \
     var##_nid = NID_##name;                                             \
-    var##_oid = der_oid_##name;                                         \
-    var##_oid_sz = sizeof(der_oid_##name);                              \
+    var##_oid = ossl_der_oid_##name;                                    \
+    var##_oid_sz = sizeof(ossl_der_oid_##name);                         \
     break;
 
-int DER_w_algorithmIdentifier_RSA(WPACKET *pkt, int tag, RSA *rsa)
+int ossl_DER_w_algorithmIdentifier_RSA(WPACKET *pkt, int tag, RSA *rsa)
 {
     int rsa_nid = NID_undef;
     const unsigned char *rsa_oid = NULL;
     size_t rsa_oid_sz = 0;
-    RSA_PSS_PARAMS_30 *pss_params = rsa_get0_pss_params_30(rsa);
+    RSA_PSS_PARAMS_30 *pss_params = ossl_rsa_get0_pss_params_30(rsa);
 
     switch (RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK)) {
     case RSA_FLAG_TYPE_RSA:
@@ -365,10 +367,10 @@ int DER_w_algorithmIdentifier_RSA(WPACKET *pkt, int tag, RSA *rsa)
     if (rsa_oid == NULL)
         return 0;
 
-    return DER_w_begin_sequence(pkt, tag)
+    return ossl_DER_w_begin_sequence(pkt, tag)
         && (rsa_nid != NID_rsassaPss
-            || rsa_pss_params_30_is_unrestricted(pss_params)
-            || DER_w_RSASSA_PSS_params(pkt, -1, pss_params))
-        && DER_w_precompiled(pkt, -1, rsa_oid, rsa_oid_sz)
-        && DER_w_end_sequence(pkt, tag);
+            || ossl_rsa_pss_params_30_is_unrestricted(pss_params)
+            || ossl_DER_w_RSASSA_PSS_params(pkt, -1, pss_params))
+        && ossl_DER_w_precompiled(pkt, -1, rsa_oid, rsa_oid_sz)
+        && ossl_DER_w_end_sequence(pkt, tag);
 }