Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool hashlib_SSLVerifySignature(const uint8_t *ca_pubkey, size_t keysize, const uint8_t *cert, size_t certlen, uint8_t sig_alg){
- if((ca_pubkey == NULL) || (cert == NULL)) return false;
- if(certlen <= keysize) return false;
- switch(sig_alg){
- case RSA_SHA256:
- {
- uint8_t sig_buf[RSA_MODULUS_MAX];
- uint8_t sha256digest[32];
- SHA256_CTX ctx;
- uint8_t mbuffer[64*4];
- memcpy(sig_buf, &cert[certlen-keysize-1], keysize);
- hashlib_RSAEncrypt(sig_buf, keysize, ca_pubkey, keysize);
- hashlib_Sha256Init(&ctx, mbuffer);
- hashlib_Sha256Update(&ctx, cert, certlen-keysize);
- hashlib_Sha256Final(&ctx, sha256digest);
- return hashlib_RSAVerifyPSS(sha256digest, 32, sig_buf, keysize);
- break;
- }
- default:
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement