der: _ossl prefix der_oid_ and der_aid_ functions

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13038)
This commit is contained in:
Pauli 2020-09-30 13:59:20 +10:00
parent a55b00bdbc
commit 0129030639
11 changed files with 69 additions and 66 deletions

View File

@ -15,7 +15,7 @@ int ossl_DER_w_algorithmIdentifier_DSA(WPACKET *pkt, int tag, DSA *dsa)
{
return ossl_DER_w_begin_sequence(pkt, tag)
/* No parameters (yet?) */
&& ossl_DER_w_precompiled(pkt, -1, der_oid_id_dsa,
sizeof(der_oid_id_dsa))
&& ossl_DER_w_precompiled(pkt, -1, ossl_der_oid_id_dsa,
sizeof(ossl_der_oid_id_dsa))
&& ossl_DER_w_end_sequence(pkt, tag);
}

View File

@ -13,8 +13,8 @@
#define MD_CASE(name) \
case NID_##name: \
precompiled = der_oid_id_dsa_with_##name; \
precompiled_sz = sizeof(der_oid_id_dsa_with_##name); \
precompiled = ossl_der_oid_id_dsa_with_##name; \
precompiled_sz = sizeof(ossl_der_oid_id_dsa_with_##name); \
break;
int ossl_DER_w_algorithmIdentifier_DSA_with_MD(WPACKET *pkt, int tag,

View File

@ -15,7 +15,7 @@ int ossl_DER_w_algorithmIdentifier_EC(WPACKET *pkt, int cont, EC_KEY *ec)
{
return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
&& ossl_DER_w_precompiled(pkt, -1, der_oid_id_ecPublicKey,
sizeof(der_oid_id_ecPublicKey))
&& ossl_DER_w_precompiled(pkt, -1, ossl_der_oid_id_ecPublicKey,
sizeof(ossl_der_oid_id_ecPublicKey))
&& ossl_DER_w_end_sequence(pkt, cont);
}

View File

@ -12,16 +12,16 @@
#include "prov/der_ec.h"
/* Aliases so we can have a uniform MD_CASE */
#define der_oid_id_ecdsa_with_sha1 der_oid_ecdsa_with_SHA1
#define der_oid_id_ecdsa_with_sha224 der_oid_ecdsa_with_SHA224
#define der_oid_id_ecdsa_with_sha256 der_oid_ecdsa_with_SHA256
#define der_oid_id_ecdsa_with_sha384 der_oid_ecdsa_with_SHA384
#define der_oid_id_ecdsa_with_sha512 der_oid_ecdsa_with_SHA512
#define ossl_der_oid_id_ecdsa_with_sha1 ossl_der_oid_ecdsa_with_SHA1
#define ossl_der_oid_id_ecdsa_with_sha224 ossl_der_oid_ecdsa_with_SHA224
#define ossl_der_oid_id_ecdsa_with_sha256 ossl_der_oid_ecdsa_with_SHA256
#define ossl_der_oid_id_ecdsa_with_sha384 ossl_der_oid_ecdsa_with_SHA384
#define ossl_der_oid_id_ecdsa_with_sha512 ossl_der_oid_ecdsa_with_SHA512
#define MD_CASE(name) \
case NID_##name: \
precompiled = der_oid_id_ecdsa_with_##name; \
precompiled_sz = sizeof(der_oid_id_ecdsa_with_##name); \
precompiled = ossl_der_oid_id_ecdsa_with_##name; \
precompiled_sz = sizeof(ossl_der_oid_id_ecdsa_with_##name); \
break;
int ossl_DER_w_algorithmIdentifier_ECDSA_with_MD(WPACKET *pkt, int cont,

View File

@ -15,8 +15,8 @@ int ossl_DER_w_algorithmIdentifier_X25519(WPACKET *pkt, int cont, ECX_KEY *ec)
{
return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
&& ossl_DER_w_precompiled(pkt, -1, der_oid_id_X25519,
sizeof(der_oid_id_X25519))
&& ossl_DER_w_precompiled(pkt, -1, ossl_der_oid_id_X25519,
sizeof(ossl_der_oid_id_X25519))
&& ossl_DER_w_end_sequence(pkt, cont);
}
@ -24,8 +24,8 @@ int ossl_DER_w_algorithmIdentifier_X448(WPACKET *pkt, int cont, ECX_KEY *ec)
{
return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
&& ossl_DER_w_precompiled(pkt, -1, der_oid_id_X448,
sizeof(der_oid_id_X448))
&& ossl_DER_w_precompiled(pkt, -1, ossl_der_oid_id_X448,
sizeof(ossl_der_oid_id_X448))
&& ossl_DER_w_end_sequence(pkt, cont);
}
@ -33,8 +33,8 @@ int ossl_DER_w_algorithmIdentifier_ED25519(WPACKET *pkt, int cont, ECX_KEY *ec)
{
return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
&& ossl_DER_w_precompiled(pkt, -1, der_oid_id_Ed25519,
sizeof(der_oid_id_Ed25519))
&& ossl_DER_w_precompiled(pkt, -1, ossl_der_oid_id_Ed25519,
sizeof(ossl_der_oid_id_Ed25519))
&& ossl_DER_w_end_sequence(pkt, cont);
}
@ -42,7 +42,7 @@ int ossl_DER_w_algorithmIdentifier_ED448(WPACKET *pkt, int cont, ECX_KEY *ec)
{
return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
&& ossl_DER_w_precompiled(pkt, -1, der_oid_id_Ed448,
sizeof(der_oid_id_Ed448))
&& ossl_DER_w_precompiled(pkt, -1, ossl_der_oid_id_Ed448,
sizeof(ossl_der_oid_id_Ed448))
&& ossl_DER_w_end_sequence(pkt, cont);
}

View 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
@ -271,8 +271,8 @@ static int DER_w_MaskGenAlgorithm(WPACKET *pkt, int tag,
#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 ossl_DER_w_RSASSA_PSS_params(WPACKET *pkt, int tag,
@ -341,12 +341,12 @@ int ossl_DER_w_RSASSA_PSS_params(WPACKET *pkt, int 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 ossl_DER_w_algorithmIdentifier_RSA(WPACKET *pkt, int tag, RSA *rsa)

View File

@ -13,19 +13,19 @@
#include "prov/der_digests.h"
/* Aliases so we can have a uniform MD_with_RSA_CASE */
#define der_oid_sha3_224WithRSAEncryption \
der_oid_id_rsassa_pkcs1_v1_5_with_sha3_224
#define der_oid_sha3_256WithRSAEncryption \
der_oid_id_rsassa_pkcs1_v1_5_with_sha3_256
#define der_oid_sha3_384WithRSAEncryption \
der_oid_id_rsassa_pkcs1_v1_5_with_sha3_384
#define der_oid_sha3_512WithRSAEncryption \
der_oid_id_rsassa_pkcs1_v1_5_with_sha3_512
#define ossl_der_oid_sha3_224WithRSAEncryption \
ossl_der_oid_id_rsassa_pkcs1_v1_5_with_sha3_224
#define ossl_der_oid_sha3_256WithRSAEncryption \
ossl_der_oid_id_rsassa_pkcs1_v1_5_with_sha3_256
#define ossl_der_oid_sha3_384WithRSAEncryption \
ossl_der_oid_id_rsassa_pkcs1_v1_5_with_sha3_384
#define ossl_der_oid_sha3_512WithRSAEncryption \
ossl_der_oid_id_rsassa_pkcs1_v1_5_with_sha3_512
#define MD_with_RSA_CASE(name, var) \
case NID_##name: \
var = der_oid_##name##WithRSAEncryption; \
var##_sz = sizeof(der_oid_##name##WithRSAEncryption); \
var = ossl_der_oid_##name##WithRSAEncryption; \
var##_sz = sizeof(ossl_der_oid_##name##WithRSAEncryption); \
break;
int ossl_DER_w_algorithmIdentifier_MDWithRSAEncryption(WPACKET *pkt, int tag,

View File

@ -17,7 +17,7 @@ int DER_w_algorithmIdentifier_SM2(WPACKET *pkt, int cont, EC_KEY *ec)
return ossl_DER_w_begin_sequence(pkt, cont)
/* No parameters (yet?) */
/* It seems SM2 identifier is the same as id_ecPublidKey */
&& ossl_DER_w_precompiled(pkt, -1, der_oid_id_ecPublicKey,
sizeof(der_oid_id_ecPublicKey))
&& ossl_DER_w_precompiled(pkt, -1, ossl_der_oid_id_ecPublicKey,
sizeof(ossl_der_oid_id_ecPublicKey))
&& ossl_DER_w_end_sequence(pkt, cont);
}

View File

@ -12,12 +12,12 @@
#include "prov/der_sm2.h"
/* Aliases so we can have a uniform MD_CASE */
#define der_oid_id_sm2_with_sm3 der_oid_sm2_with_SM3
#define ossl_der_oid_id_sm2_with_sm3 ossl_der_oid_sm2_with_SM3
#define MD_CASE(name) \
case NID_##name: \
precompiled = der_oid_id_sm2_with_##name; \
precompiled_sz = sizeof(der_oid_id_sm2_with_##name); \
precompiled = ossl_der_oid_id_sm2_with_##name; \
precompiled_sz = sizeof(ossl_der_oid_id_sm2_with_##name); \
break;
int DER_w_algorithmIdentifier_SM2_with_MD(WPACKET *pkt, int cont,

View File

@ -40,7 +40,7 @@ sub filter_to_H {
$C_comment
#define DER_OID_V_${C_name} DER_P_OBJECT, $oid_size, ${C_bytes}
#define DER_OID_SZ_${C_name} ${C_bytes_size}
extern const unsigned char der_oid_${C_name}[DER_OID_SZ_${C_name}];
extern const unsigned char ossl_der_oid_${C_name}[DER_OID_SZ_${C_name}];
_____
}
@ -58,7 +58,7 @@ sub filter_to_C {
return <<"_____";
$C_comment
const unsigned char der_oid_${C_name}[DER_OID_SZ_${C_name}] = {
const unsigned char ossl_der_oid_${C_name}[DER_OID_SZ_${C_name}] = {
DER_OID_V_${C_name}
};
_____

View File

@ -58,12 +58,15 @@ static const struct {
size_t oid_len;
size_t keklen; /* size in bytes */
} kek_algs[] = {
{ "AES-128-WRAP", der_oid_id_aes128_wrap, DER_OID_SZ_id_aes128_wrap, 16 },
{ "AES-192-WRAP", der_oid_id_aes192_wrap, DER_OID_SZ_id_aes192_wrap, 24 },
{ "AES-256-WRAP", der_oid_id_aes256_wrap, DER_OID_SZ_id_aes256_wrap, 32 },
#ifndef FIPS_MODULE
{ "DES3-WRAP", der_oid_id_alg_CMS3DESwrap, DER_OID_SZ_id_alg_CMS3DESwrap,
{ "AES-128-WRAP", ossl_der_oid_id_aes128_wrap, DER_OID_SZ_id_aes128_wrap,
16 },
{ "AES-192-WRAP", ossl_der_oid_id_aes192_wrap, DER_OID_SZ_id_aes192_wrap,
24 },
{ "AES-256-WRAP", ossl_der_oid_id_aes256_wrap, DER_OID_SZ_id_aes256_wrap,
32 },
#ifndef FIPS_MODULE
{ "DES3-WRAP", ossl_der_oid_id_alg_CMS3DESwrap,
DER_OID_SZ_id_alg_CMS3DESwrap, 24 },
#endif
};