diff --git a/ctaocrypt/src/asn.c b/ctaocrypt/src/asn.c index 96a06b937..ef0389625 100644 --- a/ctaocrypt/src/asn.c +++ b/ctaocrypt/src/asn.c @@ -2894,6 +2894,39 @@ word32 EncodeSignature(byte* out, const byte* digest, word32 digSz, int hashOID) } +int GetCTC_HashOID(int hashType) +{ + switch (hashType) { +#ifdef CYASSL_MD2 + case MD2: + return MD2h; +#endif +#ifndef NO_MD5 + case MD5: + return MD5h; +#endif +#ifndef NO_SHA + case SHA: + return SHAh; +#endif +#ifndef NO_SHA256 + case SHA256: + return SHA256h; +#endif +#ifdef CYASSL_SHA384 + case SHA384: + return SHA384h; +#endif +#ifdef CYASSL_SHA512 + case SHA512: + return SHA512h; +#endif + default: + return 0; + }; +} + + /* return true (1) or false (0) for Confirmation */ static int ConfirmSignature(const byte* buf, word32 bufSz, const byte* key, word32 keySz, word32 keyOID, diff --git a/cyassl/ctaocrypt/asn.h b/cyassl/ctaocrypt/asn.h index ff0c3f6b4..8df0b1d6c 100644 --- a/cyassl/ctaocrypt/asn.h +++ b/cyassl/ctaocrypt/asn.h @@ -499,9 +499,6 @@ CYASSL_TEST_API int ParseCert(DecodedCert*, int type, int verify, void* cm); CYASSL_LOCAL int ParseCertRelative(DecodedCert*, int type, int verify,void* cm); CYASSL_LOCAL int DecodeToKey(DecodedCert*, int verify); -CYASSL_LOCAL word32 EncodeSignature(byte* out, const byte* digest, word32 digSz, - int hashOID); - CYASSL_LOCAL Signer* MakeSigner(void*); CYASSL_LOCAL void FreeSigner(Signer*, void*); CYASSL_LOCAL void FreeSignerTable(Signer**, int, void*); diff --git a/cyassl/ctaocrypt/asn_public.h b/cyassl/ctaocrypt/asn_public.h index eca28db23..405d95368 100644 --- a/cyassl/ctaocrypt/asn_public.h +++ b/cyassl/ctaocrypt/asn_public.h @@ -181,6 +181,10 @@ CYASSL_API int SetDatesBuffer(Cert*, const byte*, int); CYASSL_API int EccKeyToDer(ecc_key*, byte* output, word32 inLen); #endif +/* DER encode signature */ +CYASSL_API word32 EncodeSignature(byte* out, const byte* digest, word32 digSz, + int hashOID); +CYASSL_API int GetCTC_HashOID(int hashType); #ifdef __cplusplus } /* extern "C" */