correctly prefix enum ltc_oid_id members

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel 2021-12-26 16:55:03 +01:00 committed by Jamie Reece Wilson
parent deaa907a5c
commit 8f9d80f171
26 changed files with 43 additions and 43 deletions

View File

@ -14,12 +14,12 @@
*/
enum ltc_oid_id {
PKA_RSA,
PKA_DSA,
PKA_EC,
PKA_EC_PRIMEF,
PKA_X25519,
PKA_ED25519,
LTC_OID_RSA,
LTC_OID_DSA,
LTC_OID_EC,
LTC_OID_EC_PRIMEF,
LTC_OID_X25519,
LTC_OID_ED25519,
};
/*

View File

@ -10,12 +10,12 @@ typedef struct {
} oid_table_entry;
static const oid_table_entry pka_oids[] = {
{ PKA_RSA, "1.2.840.113549.1.1.1" },
{ PKA_DSA, "1.2.840.10040.4.1" },
{ PKA_EC, "1.2.840.10045.2.1" },
{ PKA_EC_PRIMEF, "1.2.840.10045.1.1" },
{ PKA_X25519, "1.3.101.110" },
{ PKA_ED25519, "1.3.101.112" },
{ LTC_OID_RSA, "1.2.840.113549.1.1.1" },
{ LTC_OID_DSA, "1.2.840.10040.4.1" },
{ LTC_OID_EC, "1.2.840.10045.2.1" },
{ LTC_OID_EC_PRIMEF, "1.2.840.10045.1.1" },
{ LTC_OID_X25519, "1.3.101.110" },
{ LTC_OID_ED25519, "1.3.101.112" },
};
/*

View File

@ -81,7 +81,7 @@ int x509_decode_public_key_from_certificate(const unsigned char *in, unsigned lo
if ((l->type == LTC_ASN1_SEQUENCE)
&& (l->data != NULL)
&& LOOKS_LIKE_SPKI(l->child)) {
if (algorithm == PKA_EC) {
if (algorithm == LTC_OID_EC) {
err = callback(l->data, l->size, ctx);
} else {
err = x509_decode_subject_public_key_info(l->data, l->size,

View File

@ -75,7 +75,7 @@ int dsa_export(unsigned char *out, unsigned long *outlen, int type, const dsa_ke
LTC_SET_ASN1(int_list, 1, LTC_ASN1_INTEGER, key->q, 1UL);
LTC_SET_ASN1(int_list, 2, LTC_ASN1_INTEGER, key->g, 1UL);
err = x509_encode_subject_public_key_info(out, outlen, PKA_DSA, tmp,
err = x509_encode_subject_public_key_info(out, outlen, LTC_OID_DSA, tmp,
tmplen, LTC_ASN1_SEQUENCE, int_list,
sizeof(int_list) / sizeof(int_list[0]));

View File

@ -97,7 +97,7 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key)
}
len = 3;
err = x509_decode_subject_public_key_info(in, inlen, PKA_DSA,
err = x509_decode_subject_public_key_info(in, inlen, LTC_OID_DSA,
tmpbuf, &tmpbuf_len,
LTC_ASN1_SEQUENCE, params, &len);
if (err != CRYPT_OK) {

View File

@ -70,7 +70,7 @@ int ecc_export_openssl(unsigned char *out, unsigned long *outlen, int type, cons
if (err != CRYPT_OK) { goto error; }
/* we support only prime-field EC */
if ((err = pk_get_oid(PKA_EC_PRIMEF, &OID)) != CRYPT_OK) { goto error; }
if ((err = pk_get_oid(LTC_OID_EC_PRIMEF, &OID)) != CRYPT_OK) { goto error; }
/* http://tools.ietf.org/html/rfc3279
ECParameters ::= SEQUENCE { # SEQUENCE
@ -156,7 +156,7 @@ int ecc_export_openssl(unsigned char *out, unsigned long *outlen, int type, cons
subjectPublicKey BIT STRING # BIT STRING
}
*/
err = x509_encode_subject_public_key_info( out, outlen, PKA_EC, bin_xy, len_xy,
err = x509_encode_subject_public_key_info( out, outlen, LTC_OID_EC, bin_xy, len_xy,
ecparams.type, ecparams.data, ecparams.size );
}

View File

@ -56,7 +56,7 @@ int ecc_import_pkcs8(const unsigned char *in, unsigned long inlen,
LTC_ARGCHK(ltc_mp.name != NULL);
/* get EC alg oid */
err = pk_get_oid(PKA_EC, &pka_ec_oid);
err = pk_get_oid(LTC_OID_EC, &pka_ec_oid);
if (err != CRYPT_OK) return err;
/* init key */

View File

@ -15,7 +15,7 @@ static int s_ecc_import_x509_with_oid(const unsigned char *in, unsigned long inl
len_xy = sizeof(bin_xy);
len_oid = 16;
err = x509_decode_subject_public_key_info(in, inlen, PKA_EC, bin_xy, &len_xy,
err = x509_decode_subject_public_key_info(in, inlen, LTC_OID_EC, bin_xy, &len_xy,
LTC_ASN1_OBJECT_IDENTIFIER, (void *)curveoid, &len_oid);
if (err == CRYPT_OK) {
/* load curve parameters for given curve OID */
@ -63,7 +63,7 @@ static int s_ecc_import_x509_with_curve(const unsigned char *in, unsigned long i
/* try to load public key */
len_xy = sizeof(bin_xy);
len = 6;
err = x509_decode_subject_public_key_info(in, inlen, PKA_EC, bin_xy, &len_xy, LTC_ASN1_SEQUENCE, seq_ecparams, &len);
err = x509_decode_subject_public_key_info(in, inlen, LTC_OID_EC, bin_xy, &len_xy, LTC_ASN1_SEQUENCE, seq_ecparams, &len);
if (err == CRYPT_OK) {
len_a = seq_curve[0].size;
@ -107,7 +107,7 @@ success:
int ecc_import_x509(const unsigned char *in, unsigned long inlen, ecc_key *key)
{
return x509_decode_public_key_from_certificate(in, inlen,
PKA_EC,
LTC_OID_EC,
LTC_ASN1_EOL, NULL, NULL,
(public_key_decode_cb)ecc_import_subject_public_key_info, key);
}

View File

@ -23,7 +23,7 @@ int ed25519_export( unsigned char *out, unsigned long *outlen,
{
LTC_ARGCHK(key != NULL);
if (key->algo != PKA_ED25519) return CRYPT_PK_INVALID_TYPE;
if (key->algo != LTC_OID_ED25519) return CRYPT_PK_INVALID_TYPE;
return ec25519_export(out, outlen, which, key);
}

View File

@ -25,9 +25,9 @@ int ed25519_import(const unsigned char *in, unsigned long inlen, curve25519_key
LTC_ARGCHK(key != NULL);
key_len = sizeof(key->pub);
if ((err = x509_decode_subject_public_key_info(in, inlen, PKA_ED25519, key->pub, &key_len, LTC_ASN1_EOL, NULL, 0uL)) == CRYPT_OK) {
if ((err = x509_decode_subject_public_key_info(in, inlen, LTC_OID_ED25519, key->pub, &key_len, LTC_ASN1_EOL, NULL, 0uL)) == CRYPT_OK) {
key->type = PK_PUBLIC;
key->algo = PKA_ED25519;
key->algo = LTC_OID_ED25519;
}
return err;
}

View File

@ -22,7 +22,7 @@ int ed25519_import_pkcs8(const unsigned char *in, unsigned long inlen,
const void *pwd, unsigned long pwdlen,
curve25519_key *key)
{
return ec25519_import_pkcs8(in, inlen, pwd, pwdlen, PKA_ED25519, tweetnacl_crypto_sk_to_pk, key);
return ec25519_import_pkcs8(in, inlen, pwd, pwdlen, LTC_OID_ED25519, tweetnacl_crypto_sk_to_pk, key);
}
#endif

View File

@ -32,7 +32,7 @@ int ed25519_import_raw(const unsigned char *in, unsigned long inlen, int which,
} else {
return CRYPT_INVALID_ARG;
}
key->algo = PKA_ED25519;
key->algo = LTC_OID_ED25519;
key->type = which;
return CRYPT_OK;

View File

@ -31,13 +31,13 @@ int ed25519_import_x509(const unsigned char *in, unsigned long inlen, curve25519
LTC_ARGCHK(key != NULL);
if ((err = x509_decode_public_key_from_certificate(in, inlen,
PKA_ED25519,
LTC_OID_ED25519,
LTC_ASN1_EOL, NULL, NULL,
(public_key_decode_cb)s_ed25519_decode, key)) != CRYPT_OK) {
return err;
}
key->type = PK_PUBLIC;
key->algo = PKA_ED25519;
key->algo = LTC_OID_ED25519;
return err;
}

View File

@ -28,7 +28,7 @@ int ed25519_make_key(prng_state *prng, int wprng, curve25519_key *key)
}
key->type = PK_PRIVATE;
key->algo = PKA_ED25519;
key->algo = LTC_OID_ED25519;
return err;
}

View File

@ -30,7 +30,7 @@ int ed25519_sign(const unsigned char *msg, unsigned long msglen,
LTC_ARGCHK(siglen != NULL);
LTC_ARGCHK(private_key != NULL);
if (private_key->algo != PKA_ED25519) return CRYPT_PK_INVALID_TYPE;
if (private_key->algo != LTC_OID_ED25519) return CRYPT_PK_INVALID_TYPE;
if (private_key->type != PK_PRIVATE) return CRYPT_PK_INVALID_TYPE;
if (*siglen < 64uL) {

View File

@ -34,7 +34,7 @@ int ed25519_verify(const unsigned char *msg, unsigned long msglen,
*stat = 0;
if (siglen != 64uL) return CRYPT_INVALID_ARG;
if (public_key->algo != PKA_ED25519) return CRYPT_PK_INVALID_TYPE;
if (public_key->algo != LTC_OID_ED25519) return CRYPT_PK_INVALID_TYPE;
mlen = msglen + siglen;
if ((mlen < msglen) || (mlen < siglen)) return CRYPT_OVERFLOW;

View File

@ -78,7 +78,7 @@ int rsa_export(unsigned char *out, unsigned long *outlen, int type, const rsa_ke
}
err = x509_encode_subject_public_key_info(out, outlen,
PKA_RSA, tmp, tmplen, LTC_ASN1_NULL, NULL, 0);
LTC_OID_RSA, tmp, tmplen, LTC_ASN1_NULL, NULL, 0);
finish:
if (tmp != out) XFREE(tmp);

View File

@ -42,7 +42,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key)
len = 0;
err = x509_decode_subject_public_key_info(in, inlen,
PKA_RSA, tmpbuf, &tmpbuf_len,
LTC_OID_RSA, tmpbuf, &tmpbuf_len,
LTC_ASN1_NULL, NULL, &len);
if (err == CRYPT_OK) { /* SubjectPublicKeyInfo format */

View File

@ -61,7 +61,7 @@ int rsa_import_pkcs8(const unsigned char *in, unsigned long inlen,
LTC_ARGCHK(ltc_mp.name != NULL);
/* get RSA alg oid */
err = pk_get_oid(PKA_RSA, &rsaoid);
err = pk_get_oid(LTC_OID_RSA, &rsaoid);
if (err != CRYPT_OK) { goto LBL_NOFREE; }
/* alloc buffers */

View File

@ -39,7 +39,7 @@ int rsa_import_x509(const unsigned char *in, unsigned long inlen, rsa_key *key)
}
if ((err = x509_decode_public_key_from_certificate(in, inlen,
PKA_RSA, LTC_ASN1_NULL,
LTC_OID_RSA, LTC_ASN1_NULL,
NULL, NULL,
(public_key_decode_cb)s_rsa_decode, key)) != CRYPT_OK) {
rsa_free(key);

View File

@ -23,7 +23,7 @@ int x25519_export( unsigned char *out, unsigned long *outlen,
{
LTC_ARGCHK(key != NULL);
if (key->algo != PKA_X25519) return CRYPT_PK_INVALID_TYPE;
if (key->algo != LTC_OID_X25519) return CRYPT_PK_INVALID_TYPE;
return ec25519_export(out, outlen, which, key);
}

View File

@ -25,9 +25,9 @@ int x25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *
LTC_ARGCHK(key != NULL);
key_len = sizeof(key->pub);
if ((err = x509_decode_subject_public_key_info(in, inlen, PKA_X25519, key->pub, &key_len, LTC_ASN1_EOL, NULL, 0uL)) == CRYPT_OK) {
if ((err = x509_decode_subject_public_key_info(in, inlen, LTC_OID_X25519, key->pub, &key_len, LTC_ASN1_EOL, NULL, 0uL)) == CRYPT_OK) {
key->type = PK_PUBLIC;
key->algo = PKA_X25519;
key->algo = LTC_OID_X25519;
}
return err;
}

View File

@ -22,7 +22,7 @@ int x25519_import_pkcs8(const unsigned char *in, unsigned long inlen,
const void *pwd, unsigned long pwdlen,
curve25519_key *key)
{
return ec25519_import_pkcs8(in, inlen, pwd, pwdlen, PKA_X25519, tweetnacl_crypto_scalarmult_base, key);
return ec25519_import_pkcs8(in, inlen, pwd, pwdlen, LTC_OID_X25519, tweetnacl_crypto_scalarmult_base, key);
}
#endif

View File

@ -32,7 +32,7 @@ int x25519_import_raw(const unsigned char *in, unsigned long inlen, int which, c
} else {
return CRYPT_INVALID_ARG;
}
key->algo = PKA_X25519;
key->algo = LTC_OID_X25519;
key->type = which;
return CRYPT_OK;

View File

@ -31,13 +31,13 @@ int x25519_import_x509(const unsigned char *in, unsigned long inlen, curve25519_
LTC_ARGCHK(key != NULL);
if ((err = x509_decode_public_key_from_certificate(in, inlen,
PKA_X25519,
LTC_OID_X25519,
LTC_ASN1_EOL, NULL, NULL,
(public_key_decode_cb)s_x25519_decode, key)) != CRYPT_OK) {
return err;
}
key->type = PK_PUBLIC;
key->algo = PKA_X25519;
key->algo = LTC_OID_X25519;
return err;
}

View File

@ -34,7 +34,7 @@ int x25519_make_key(prng_state *prng, int wprng, curve25519_key *key)
tweetnacl_crypto_scalarmult_base(key->pub, key->priv);
key->type = PK_PRIVATE;
key->algo = PKA_X25519;
key->algo = LTC_OID_X25519;
return err;
}