add pk_oid_cmp_with_asn1()
This commit is contained in:
parent
e318f6f1e3
commit
645460a5d5
@ -303,6 +303,8 @@ int x509_decode_subject_public_key_info(const unsigned char *in, unsigned long i
|
||||
unsigned int algorithm, void* public_key, unsigned long* public_key_len,
|
||||
ltc_asn1_type parameters_type, ltc_asn1_list* parameters, unsigned long *parameters_len);
|
||||
|
||||
int pk_oid_cmp_with_asn1(const char *o1, const ltc_asn1_list *o2);
|
||||
|
||||
#endif /* LTC_DER */
|
||||
|
||||
/* tomcrypt_pkcs.h */
|
||||
|
43
src/pk/asn1/oid/pk_oid_asn1.c
Normal file
43
src/pk/asn1/oid/pk_oid_asn1.c
Normal file
@ -0,0 +1,43 @@
|
||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||
*
|
||||
* LibTomCrypt is a library that provides various cryptographic
|
||||
* algorithms in a highly modular and flexible manner.
|
||||
*
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*/
|
||||
#include "tomcrypt_private.h"
|
||||
|
||||
#ifdef LTC_DER
|
||||
|
||||
/*
|
||||
Compare an OID string to an OID element decoded from ASN.1.
|
||||
@return CRYPT_OK if equal
|
||||
*/
|
||||
int pk_oid_cmp_with_asn1(const char *o1, const ltc_asn1_list *o2)
|
||||
{
|
||||
unsigned long i;
|
||||
char tmp[256] = { 0 };
|
||||
int err;
|
||||
|
||||
if (o1 == NULL || o2 == NULL) return CRYPT_ERROR;
|
||||
|
||||
if (o2->type != LTC_ASN1_OBJECT_IDENTIFIER) return CRYPT_INVALID_ARG;
|
||||
|
||||
i = sizeof(tmp);
|
||||
if ((err = pk_oid_num_to_str(o2->data, o2->size, tmp, &i)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (XSTRCMP(o1, tmp) != 0) {
|
||||
return CRYPT_PK_INVALID_TYPE;
|
||||
}
|
||||
|
||||
return CRYPT_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ref: $Format:%D$ */
|
||||
/* git commit: $Format:%H$ */
|
||||
/* commit time: $Format:%ai$ */
|
Loading…
Reference in New Issue
Block a user