瀏覽代碼

fix naming of SubjectPublicKeyInfo de-&encoder

Steffen Jaeckel 8 年之前
父節點
當前提交
54dd6ce840

+ 11 - 8
src/headers/tomcrypt_pk.h

@@ -567,14 +567,6 @@ int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
 /* internal helper functions */
 /* internal helper functions */
 int der_length_sequence_ex(ltc_asn1_list *list, unsigned long inlen,
 int der_length_sequence_ex(ltc_asn1_list *list, unsigned long inlen,
                            unsigned long *outlen, unsigned long *payloadlen);
                            unsigned long *outlen, unsigned long *payloadlen);
-/* SUBJECT PUBLIC KEY INFO */
-int der_encode_subject_public_key_info(unsigned char *out, unsigned long *outlen,
-        unsigned int algorithm, void* public_key, unsigned long public_key_len,
-        unsigned long parameters_type, void* parameters, unsigned long parameters_len);
-
-int der_decode_subject_public_key_info(const unsigned char *in, unsigned long inlen,
-        unsigned int algorithm, void* public_key, unsigned long* public_key_len,
-        unsigned long parameters_type, void* parameters, unsigned long *parameters_len);
 #endif /* LTC_SOURCE */
 #endif /* LTC_SOURCE */
 
 
 /* SET */
 /* SET */
@@ -744,6 +736,17 @@ int der_decode_generalizedtime(const unsigned char *in, unsigned long *inlen,
 
 
 int der_length_generalizedtime(ltc_generalizedtime *gtime, unsigned long *outlen);
 int der_length_generalizedtime(ltc_generalizedtime *gtime, unsigned long *outlen);
 
 
+#ifdef LTC_SOURCE
+/* internal helper functions */
+/* SUBJECT PUBLIC KEY INFO */
+int x509_encode_subject_public_key_info(unsigned char *out, unsigned long *outlen,
+        unsigned int algorithm, void* public_key, unsigned long public_key_len,
+        unsigned long parameters_type, void* parameters, unsigned long parameters_len);
+
+int x509_decode_subject_public_key_info(const unsigned char *in, unsigned long inlen,
+        unsigned int algorithm, void* public_key, unsigned long* public_key_len,
+        unsigned long parameters_type, void* parameters, unsigned long *parameters_len);
+#endif /* LTC_SOURCE */
 
 
 #endif
 #endif
 
 

+ 5 - 4
src/pk/asn1/der/sequence/der_decode_subject_public_key_info.c → src/pk/asn1/x509/x509_decode_subject_public_key_info.c

@@ -7,9 +7,10 @@
  * guarantee it works.
  * guarantee it works.
  */
  */
 #include "tomcrypt.h"
 #include "tomcrypt.h"
+
 /**
 /**
-  @file der_decode_subject_public_key_info.c
-  ASN.1 DER, encode a Subject Public Key structure --nmav
+  @file x509_decode_subject_public_key_info.c
+  ASN.1 DER/X.509, encode a SubjectPublicKeyInfo structure --nmav
 */
 */
 
 
 #ifdef LTC_DER
 #ifdef LTC_DER
@@ -25,7 +26,7 @@
  * }
  * }
  */
  */
 /**
 /**
-  Decode a subject public key info
+  Decode a SubjectPublicKeyInfo
    @param in      The input buffer
    @param in      The input buffer
    @param inlen   The length of the input buffer
    @param inlen   The length of the input buffer
    @param algorithm             One out of the enum #public_key_algorithms
    @param algorithm             One out of the enum #public_key_algorithms
@@ -36,7 +37,7 @@
    @param parameters_len        [in/out]The number of parameters to include
    @param parameters_len        [in/out]The number of parameters to include
    @return CRYPT_OK on success
    @return CRYPT_OK on success
 */
 */
-int der_decode_subject_public_key_info(const unsigned char *in, unsigned long inlen,
+int x509_decode_subject_public_key_info(const unsigned char *in, unsigned long inlen,
         unsigned int algorithm, void* public_key, unsigned long* public_key_len,
         unsigned int algorithm, void* public_key, unsigned long* public_key_len,
         unsigned long parameters_type, void* parameters, unsigned long *parameters_len)
         unsigned long parameters_type, void* parameters, unsigned long *parameters_len)
 {
 {

+ 4 - 4
src/pk/asn1/der/sequence/der_encode_subject_public_key_info.c → src/pk/asn1/x509/x509_encode_subject_public_key_info.c

@@ -9,8 +9,8 @@
 #include "tomcrypt.h"
 #include "tomcrypt.h"
 
 
 /**
 /**
-  @file der_encode_subject_public_key_info.c
-  ASN.1 DER, encode a Subject Public Key structure --nmav
+  @file x509_encode_subject_public_key_info.c
+  ASN.1 DER/X.509, encode a SubjectPublicKeyInfo structure --nmav
 */
 */
 
 
 #ifdef LTC_DER
 #ifdef LTC_DER
@@ -26,7 +26,7 @@
  * }
  * }
  */
  */
 /**
 /**
-  Encode a subject public key info
+  Encode a SubjectPublicKeyInfo
    @param out           The output buffer
    @param out           The output buffer
    @param outlen        [in/out] Length of buffer and resulting length of output
    @param outlen        [in/out] Length of buffer and resulting length of output
    @param algorithm             One out of the enum #public_key_algorithms
    @param algorithm             One out of the enum #public_key_algorithms
@@ -37,7 +37,7 @@
    @param parameters_len        The number of parameters to include
    @param parameters_len        The number of parameters to include
    @return CRYPT_OK on success
    @return CRYPT_OK on success
 */
 */
-int der_encode_subject_public_key_info(unsigned char *out, unsigned long *outlen,
+int x509_encode_subject_public_key_info(unsigned char *out, unsigned long *outlen,
         unsigned int algorithm, void* public_key, unsigned long public_key_len,
         unsigned int algorithm, void* public_key, unsigned long public_key_len,
         unsigned long parameters_type, void* parameters, unsigned long parameters_len)
         unsigned long parameters_type, void* parameters, unsigned long parameters_len)
 {
 {

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

@@ -86,7 +86,7 @@ int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key
           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 = der_encode_subject_public_key_info(out, outlen, PKA_DSA, tmp,
+          err = x509_encode_subject_public_key_info(out, outlen, PKA_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]));
 
 

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

@@ -103,7 +103,7 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key)
       }
       }
 
 
       len = 3;
       len = 3;
-      err = der_decode_subject_public_key_info(in, inlen, PKA_DSA,
+      err = x509_decode_subject_public_key_info(in, inlen, PKA_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) {

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

@@ -79,7 +79,7 @@ int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key
           goto finish;
           goto finish;
       }
       }
 
 
-      err = der_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);
         PKA_RSA, tmp, tmplen, LTC_ASN1_NULL, NULL, 0);
 
 
 finish:
 finish:

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

@@ -48,7 +48,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key)
    }
    }
 
 
    len = 0;
    len = 0;
-   err = der_decode_subject_public_key_info(in, inlen,
+   err = x509_decode_subject_public_key_info(in, inlen,
         PKA_RSA, tmpbuf, &tmpbuf_len,
         PKA_RSA, tmpbuf, &tmpbuf_len,
         LTC_ASN1_NULL, NULL, &len);
         LTC_ASN1_NULL, NULL, &len);
 
 

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

@@ -78,7 +78,7 @@ int rsa_import_x509(const unsigned char *in, unsigned long inlen, rsa_key *key)
                      l->child->child->type == LTC_ASN1_OBJECT_IDENTIFIER && l->child->next &&
                      l->child->child->type == LTC_ASN1_OBJECT_IDENTIFIER && l->child->next &&
                      l->child->next->type == LTC_ASN1_BIT_STRING) {
                      l->child->next->type == LTC_ASN1_BIT_STRING) {
                   len = 0;
                   len = 0;
-                  err = der_decode_subject_public_key_info(l->data, l->size,
+                  err = x509_decode_subject_public_key_info(l->data, l->size,
                        PKA_RSA, tmpbuf, &tmpbuf_len,
                        PKA_RSA, tmpbuf, &tmpbuf_len,
                        LTC_ASN1_NULL, NULL, &len);
                        LTC_ASN1_NULL, NULL, &len);
                   if (err == CRYPT_OK) {
                   if (err == CRYPT_OK) {