Advertisement
AnthonyCagliano

Untitled

Nov 24th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #define RSA_PUBLIC_EXP 65537
  2. bool hashlib_RSAEncrypt(const uint8_t* msg, size_t msglen, uint8_t *ct, const uint8_t* pubkey, size_t keylen){
  3. if(msg==NULL || pubkey==NULL) return false;
  4. if(msglen != keylen) return false;
  5. uint8_t spos = 0;
  6. while(pubkey[spos++]==0) ct[spos] = 0;
  7. hashlib_RSAEncodeOAEP(msg, msglen, &ct[spos], keylen-spos, NULL)
  8. powmod((uint8_t)keylen, ct, RSA_PUBLIC_EXP, pubkey);
  9. return true;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement