浏览代码

correctly prefix `enum ltc_oid_id` members

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel 3 年之前
父节点
当前提交
a24af5f7e1

+ 6 - 6
src/headers/tomcrypt_private.h

@@ -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,
 };
 
 /*

+ 6 - 6
src/pk/asn1/oid/pk_get_oid.c

@@ -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" },
 };
 
 /*

+ 1 - 1
src/pk/asn1/x509/x509_decode_public_key_from_certificate.c

@@ -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,

+ 1 - 1
src/pk/dsa/dsa_export.c

@@ -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]));
 

+ 1 - 1
src/pk/dsa/dsa_import.c

@@ -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) {

+ 2 - 2
src/pk/ecc/ecc_export_openssl.c

@@ -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 );
    }
 

+ 1 - 1
src/pk/ecc/ecc_import_pkcs8.c

@@ -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 */

+ 3 - 3
src/pk/ecc/ecc_import_x509.c

@@ -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);
 }

+ 1 - 1
src/pk/ed25519/ed25519_export.c

@@ -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);
 }

+ 2 - 2
src/pk/ed25519/ed25519_import.c

@@ -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;
 }

+ 1 - 1
src/pk/ed25519/ed25519_import_pkcs8.c

@@ -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

+ 1 - 1
src/pk/ed25519/ed25519_import_raw.c

@@ -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;

+ 2 - 2
src/pk/ed25519/ed25519_import_x509.c

@@ -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;
 }

+ 1 - 1
src/pk/ed25519/ed25519_make_key.c

@@ -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;
 }

+ 1 - 1
src/pk/ed25519/ed25519_sign.c

@@ -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) {

+ 1 - 1
src/pk/ed25519/ed25519_verify.c

@@ -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;

+ 1 - 1
src/pk/rsa/rsa_export.c

@@ -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);

+ 1 - 1
src/pk/rsa/rsa_import.c

@@ -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 */

+ 1 - 1
src/pk/rsa/rsa_import_pkcs8.c

@@ -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 */

+ 1 - 1
src/pk/rsa/rsa_import_x509.c

@@ -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);

+ 1 - 1
src/pk/x25519/x25519_export.c

@@ -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);
 }

+ 2 - 2
src/pk/x25519/x25519_import.c

@@ -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;
 }

+ 1 - 1
src/pk/x25519/x25519_import_pkcs8.c

@@ -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

+ 1 - 1
src/pk/x25519/x25519_import_raw.c

@@ -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;

+ 2 - 2
src/pk/x25519/x25519_import_x509.c

@@ -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;
 }

+ 1 - 1
src/pk/x25519/x25519_make_key.c

@@ -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;
 }