correctly prefix enum ltc_oid_id
members
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
parent
deaa907a5c
commit
8f9d80f171
@ -14,12 +14,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
enum ltc_oid_id {
|
enum ltc_oid_id {
|
||||||
PKA_RSA,
|
LTC_OID_RSA,
|
||||||
PKA_DSA,
|
LTC_OID_DSA,
|
||||||
PKA_EC,
|
LTC_OID_EC,
|
||||||
PKA_EC_PRIMEF,
|
LTC_OID_EC_PRIMEF,
|
||||||
PKA_X25519,
|
LTC_OID_X25519,
|
||||||
PKA_ED25519,
|
LTC_OID_ED25519,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -10,12 +10,12 @@ typedef struct {
|
|||||||
} oid_table_entry;
|
} oid_table_entry;
|
||||||
|
|
||||||
static const oid_table_entry pka_oids[] = {
|
static const oid_table_entry pka_oids[] = {
|
||||||
{ PKA_RSA, "1.2.840.113549.1.1.1" },
|
{ LTC_OID_RSA, "1.2.840.113549.1.1.1" },
|
||||||
{ PKA_DSA, "1.2.840.10040.4.1" },
|
{ LTC_OID_DSA, "1.2.840.10040.4.1" },
|
||||||
{ PKA_EC, "1.2.840.10045.2.1" },
|
{ LTC_OID_EC, "1.2.840.10045.2.1" },
|
||||||
{ PKA_EC_PRIMEF, "1.2.840.10045.1.1" },
|
{ LTC_OID_EC_PRIMEF, "1.2.840.10045.1.1" },
|
||||||
{ PKA_X25519, "1.3.101.110" },
|
{ LTC_OID_X25519, "1.3.101.110" },
|
||||||
{ PKA_ED25519, "1.3.101.112" },
|
{ LTC_OID_ED25519, "1.3.101.112" },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -81,7 +81,7 @@ int x509_decode_public_key_from_certificate(const unsigned char *in, unsigned lo
|
|||||||
if ((l->type == LTC_ASN1_SEQUENCE)
|
if ((l->type == LTC_ASN1_SEQUENCE)
|
||||||
&& (l->data != NULL)
|
&& (l->data != NULL)
|
||||||
&& LOOKS_LIKE_SPKI(l->child)) {
|
&& LOOKS_LIKE_SPKI(l->child)) {
|
||||||
if (algorithm == PKA_EC) {
|
if (algorithm == LTC_OID_EC) {
|
||||||
err = callback(l->data, l->size, ctx);
|
err = callback(l->data, l->size, ctx);
|
||||||
} else {
|
} else {
|
||||||
err = x509_decode_subject_public_key_info(l->data, l->size,
|
err = x509_decode_subject_public_key_info(l->data, l->size,
|
||||||
|
@ -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, 1, LTC_ASN1_INTEGER, key->q, 1UL);
|
||||||
LTC_SET_ASN1(int_list, 2, LTC_ASN1_INTEGER, key->g, 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,
|
tmplen, LTC_ASN1_SEQUENCE, int_list,
|
||||||
sizeof(int_list) / sizeof(int_list[0]));
|
sizeof(int_list) / sizeof(int_list[0]));
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
len = 3;
|
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,
|
tmpbuf, &tmpbuf_len,
|
||||||
LTC_ASN1_SEQUENCE, params, &len);
|
LTC_ASN1_SEQUENCE, params, &len);
|
||||||
if (err != CRYPT_OK) {
|
if (err != CRYPT_OK) {
|
||||||
|
@ -70,7 +70,7 @@ int ecc_export_openssl(unsigned char *out, unsigned long *outlen, int type, cons
|
|||||||
if (err != CRYPT_OK) { goto error; }
|
if (err != CRYPT_OK) { goto error; }
|
||||||
|
|
||||||
/* we support only prime-field EC */
|
/* 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
|
/* http://tools.ietf.org/html/rfc3279
|
||||||
ECParameters ::= SEQUENCE { # SEQUENCE
|
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
|
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 );
|
ecparams.type, ecparams.data, ecparams.size );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ int ecc_import_pkcs8(const unsigned char *in, unsigned long inlen,
|
|||||||
LTC_ARGCHK(ltc_mp.name != NULL);
|
LTC_ARGCHK(ltc_mp.name != NULL);
|
||||||
|
|
||||||
/* get EC alg oid */
|
/* 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;
|
if (err != CRYPT_OK) return err;
|
||||||
|
|
||||||
/* init key */
|
/* init key */
|
||||||
|
@ -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_xy = sizeof(bin_xy);
|
||||||
len_oid = 16;
|
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);
|
LTC_ASN1_OBJECT_IDENTIFIER, (void *)curveoid, &len_oid);
|
||||||
if (err == CRYPT_OK) {
|
if (err == CRYPT_OK) {
|
||||||
/* load curve parameters for given curve OID */
|
/* 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 */
|
/* try to load public key */
|
||||||
len_xy = sizeof(bin_xy);
|
len_xy = sizeof(bin_xy);
|
||||||
len = 6;
|
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) {
|
if (err == CRYPT_OK) {
|
||||||
len_a = seq_curve[0].size;
|
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)
|
int ecc_import_x509(const unsigned char *in, unsigned long inlen, ecc_key *key)
|
||||||
{
|
{
|
||||||
return x509_decode_public_key_from_certificate(in, inlen,
|
return x509_decode_public_key_from_certificate(in, inlen,
|
||||||
PKA_EC,
|
LTC_OID_EC,
|
||||||
LTC_ASN1_EOL, NULL, NULL,
|
LTC_ASN1_EOL, NULL, NULL,
|
||||||
(public_key_decode_cb)ecc_import_subject_public_key_info, key);
|
(public_key_decode_cb)ecc_import_subject_public_key_info, key);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ int ed25519_export( unsigned char *out, unsigned long *outlen,
|
|||||||
{
|
{
|
||||||
LTC_ARGCHK(key != NULL);
|
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);
|
return ec25519_export(out, outlen, which, key);
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ int ed25519_import(const unsigned char *in, unsigned long inlen, curve25519_key
|
|||||||
LTC_ARGCHK(key != NULL);
|
LTC_ARGCHK(key != NULL);
|
||||||
|
|
||||||
key_len = sizeof(key->pub);
|
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->type = PK_PUBLIC;
|
||||||
key->algo = PKA_ED25519;
|
key->algo = LTC_OID_ED25519;
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ int ed25519_import_pkcs8(const unsigned char *in, unsigned long inlen,
|
|||||||
const void *pwd, unsigned long pwdlen,
|
const void *pwd, unsigned long pwdlen,
|
||||||
curve25519_key *key)
|
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
|
#endif
|
||||||
|
@ -32,7 +32,7 @@ int ed25519_import_raw(const unsigned char *in, unsigned long inlen, int which,
|
|||||||
} else {
|
} else {
|
||||||
return CRYPT_INVALID_ARG;
|
return CRYPT_INVALID_ARG;
|
||||||
}
|
}
|
||||||
key->algo = PKA_ED25519;
|
key->algo = LTC_OID_ED25519;
|
||||||
key->type = which;
|
key->type = which;
|
||||||
|
|
||||||
return CRYPT_OK;
|
return CRYPT_OK;
|
||||||
|
@ -31,13 +31,13 @@ int ed25519_import_x509(const unsigned char *in, unsigned long inlen, curve25519
|
|||||||
LTC_ARGCHK(key != NULL);
|
LTC_ARGCHK(key != NULL);
|
||||||
|
|
||||||
if ((err = x509_decode_public_key_from_certificate(in, inlen,
|
if ((err = x509_decode_public_key_from_certificate(in, inlen,
|
||||||
PKA_ED25519,
|
LTC_OID_ED25519,
|
||||||
LTC_ASN1_EOL, NULL, NULL,
|
LTC_ASN1_EOL, NULL, NULL,
|
||||||
(public_key_decode_cb)s_ed25519_decode, key)) != CRYPT_OK) {
|
(public_key_decode_cb)s_ed25519_decode, key)) != CRYPT_OK) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
key->type = PK_PUBLIC;
|
key->type = PK_PUBLIC;
|
||||||
key->algo = PKA_ED25519;
|
key->algo = LTC_OID_ED25519;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ int ed25519_make_key(prng_state *prng, int wprng, curve25519_key *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
key->type = PK_PRIVATE;
|
key->type = PK_PRIVATE;
|
||||||
key->algo = PKA_ED25519;
|
key->algo = LTC_OID_ED25519;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ int ed25519_sign(const unsigned char *msg, unsigned long msglen,
|
|||||||
LTC_ARGCHK(siglen != NULL);
|
LTC_ARGCHK(siglen != NULL);
|
||||||
LTC_ARGCHK(private_key != 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 (private_key->type != PK_PRIVATE) return CRYPT_PK_INVALID_TYPE;
|
||||||
|
|
||||||
if (*siglen < 64uL) {
|
if (*siglen < 64uL) {
|
||||||
|
@ -34,7 +34,7 @@ int ed25519_verify(const unsigned char *msg, unsigned long msglen,
|
|||||||
*stat = 0;
|
*stat = 0;
|
||||||
|
|
||||||
if (siglen != 64uL) return CRYPT_INVALID_ARG;
|
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;
|
mlen = msglen + siglen;
|
||||||
if ((mlen < msglen) || (mlen < siglen)) return CRYPT_OVERFLOW;
|
if ((mlen < msglen) || (mlen < siglen)) return CRYPT_OVERFLOW;
|
||||||
|
@ -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,
|
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:
|
finish:
|
||||||
if (tmp != out) XFREE(tmp);
|
if (tmp != out) XFREE(tmp);
|
||||||
|
@ -42,7 +42,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key)
|
|||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
err = x509_decode_subject_public_key_info(in, inlen,
|
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);
|
LTC_ASN1_NULL, NULL, &len);
|
||||||
|
|
||||||
if (err == CRYPT_OK) { /* SubjectPublicKeyInfo format */
|
if (err == CRYPT_OK) { /* SubjectPublicKeyInfo format */
|
||||||
|
@ -61,7 +61,7 @@ int rsa_import_pkcs8(const unsigned char *in, unsigned long inlen,
|
|||||||
LTC_ARGCHK(ltc_mp.name != NULL);
|
LTC_ARGCHK(ltc_mp.name != NULL);
|
||||||
|
|
||||||
/* get RSA alg oid */
|
/* 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; }
|
if (err != CRYPT_OK) { goto LBL_NOFREE; }
|
||||||
|
|
||||||
/* alloc buffers */
|
/* alloc buffers */
|
||||||
|
@ -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,
|
if ((err = x509_decode_public_key_from_certificate(in, inlen,
|
||||||
PKA_RSA, LTC_ASN1_NULL,
|
LTC_OID_RSA, LTC_ASN1_NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
(public_key_decode_cb)s_rsa_decode, key)) != CRYPT_OK) {
|
(public_key_decode_cb)s_rsa_decode, key)) != CRYPT_OK) {
|
||||||
rsa_free(key);
|
rsa_free(key);
|
||||||
|
@ -23,7 +23,7 @@ int x25519_export( unsigned char *out, unsigned long *outlen,
|
|||||||
{
|
{
|
||||||
LTC_ARGCHK(key != NULL);
|
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);
|
return ec25519_export(out, outlen, which, key);
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ int x25519_import(const unsigned char *in, unsigned long inlen, curve25519_key *
|
|||||||
LTC_ARGCHK(key != NULL);
|
LTC_ARGCHK(key != NULL);
|
||||||
|
|
||||||
key_len = sizeof(key->pub);
|
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->type = PK_PUBLIC;
|
||||||
key->algo = PKA_X25519;
|
key->algo = LTC_OID_X25519;
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ int x25519_import_pkcs8(const unsigned char *in, unsigned long inlen,
|
|||||||
const void *pwd, unsigned long pwdlen,
|
const void *pwd, unsigned long pwdlen,
|
||||||
curve25519_key *key)
|
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
|
#endif
|
||||||
|
@ -32,7 +32,7 @@ int x25519_import_raw(const unsigned char *in, unsigned long inlen, int which, c
|
|||||||
} else {
|
} else {
|
||||||
return CRYPT_INVALID_ARG;
|
return CRYPT_INVALID_ARG;
|
||||||
}
|
}
|
||||||
key->algo = PKA_X25519;
|
key->algo = LTC_OID_X25519;
|
||||||
key->type = which;
|
key->type = which;
|
||||||
|
|
||||||
return CRYPT_OK;
|
return CRYPT_OK;
|
||||||
|
@ -31,13 +31,13 @@ int x25519_import_x509(const unsigned char *in, unsigned long inlen, curve25519_
|
|||||||
LTC_ARGCHK(key != NULL);
|
LTC_ARGCHK(key != NULL);
|
||||||
|
|
||||||
if ((err = x509_decode_public_key_from_certificate(in, inlen,
|
if ((err = x509_decode_public_key_from_certificate(in, inlen,
|
||||||
PKA_X25519,
|
LTC_OID_X25519,
|
||||||
LTC_ASN1_EOL, NULL, NULL,
|
LTC_ASN1_EOL, NULL, NULL,
|
||||||
(public_key_decode_cb)s_x25519_decode, key)) != CRYPT_OK) {
|
(public_key_decode_cb)s_x25519_decode, key)) != CRYPT_OK) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
key->type = PK_PUBLIC;
|
key->type = PK_PUBLIC;
|
||||||
key->algo = PKA_X25519;
|
key->algo = LTC_OID_X25519;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ int x25519_make_key(prng_state *prng, int wprng, curve25519_key *key)
|
|||||||
tweetnacl_crypto_scalarmult_base(key->pub, key->priv);
|
tweetnacl_crypto_scalarmult_base(key->pub, key->priv);
|
||||||
|
|
||||||
key->type = PK_PRIVATE;
|
key->type = PK_PRIVATE;
|
||||||
key->algo = PKA_X25519;
|
key->algo = LTC_OID_X25519;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user