Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define RSA_PUBLIC_EXP 65537
- bool hashlib_RSAEncrypt(const uint8_t* msg, size_t msglen, uint8_t *ct, const uint8_t* pubkey, size_t keylen){
- if(msg==NULL || pubkey==NULL) return false;
- if(msglen != keylen) return false;
- uint8_t spos = 0;
- while(pubkey[spos++]==0) ct[spos] = 0;
- hashlib_RSAEncodeOAEP(msg, msglen, &ct[spos], keylen-spos, NULL)
- powmod((uint8_t)keylen, ct, RSA_PUBLIC_EXP, pubkey);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement