Lines Matching refs:rsa
124 static bool validateSignature(uint8_t *sigPack, struct RsaData *rsa, bool verbose, uint32_t *refHas… in validateSignature() argument
131 rsa->num[i] = le32toh(le32SigPack[i]); in validateSignature()
134 printHashRev(stderr, "RSA cyphertext", rsa->num, RSA_LIMBS); in validateSignature()
136 memcpy(rsa->modulus, sigPack + RSA_BYTES, RSA_BYTES); in validateSignature()
139 rsaResult = rsaPubOp(&rsa->state, rsa->num, rsa->modulus); in validateSignature()
191 static int handleConvertKey(uint8_t **pbuf, uint32_t bufUsed, FILE *out, struct RsaData *rsa) in handleConvertKey() argument
217 rsa->num[RSA_LIMBS - i - 1] = be32toh(be32Buf[i]); in handleConvertKey()
220 ret = fwrite(rsa->num, 1, RSA_BYTES, out) == RSA_BYTES ? 0 : 2; in handleConvertKey()
226 static int handleVerify(uint8_t **pbuf, uint32_t bufUsed, struct RsaData *rsa, bool verbose, bool b… in handleVerify() argument
232 memcpy(masterPubKey, rsa->modulus, RSA_BYTES); in handleVerify()
266 … if (!validateSignature(sigPack, rsa, verbose, (uint32_t*)sha2finish(&shaState), false)) { in handleVerify()
270 if (memcmp(masterPubKey, rsa->modulus, RSA_BYTES) == 0) { in handleVerify()
296 if (!validateSignature(sigPack, rsa, verbose, hash, false)) { in handleVerify()
316 static int handleSign(uint8_t **pbuf, uint32_t bufUsed, FILE *out, struct RsaData *rsa, bool verbos… in handleSign() argument
369 memcpy(rsa->num, hash, SHA2_HASH_SIZE); in handleSign()
373 rsa->num[i++] = rand32_no_zero_bytes() << 8; //low byte here must be zero as per padding spec in handleSign()
375 rsa->num[i] = rand32_no_zero_bytes(); in handleSign()
376 rsa->num[i] = (rand32_no_zero_bytes() >> 16) | 0x00020000; //as per padding spec in handleSign()
380 printHashRev(stderr, "RSA plaintext", rsa->num, RSA_LIMBS); in handleSign()
384 rsaResult = rsaPrivOp(&rsa->state, rsa->num, rsa->exponent, rsa->modulus); in handleSign()
395 ret = (fwrite(rsa->modulus, 1, RSA_BYTES, out) == RSA_BYTES) ? 0 : 2; in handleSign()
440 struct RsaData rsa; in main() local
494 memset(&rsa, 0, sizeof(rsa)); in main()
503 if (!readFile(rsa.exponent, sizeof(rsa.exponent), keyPvtFile)) in main()
507 printHashRev(stderr, "RSA exponent", rsa.exponent, RSA_LIMBS); in main()
512 if (!readFile(rsa.modulus, sizeof(rsa.modulus), keyPubFile)) in main()
515 printHashRev(stderr, "RSA modulus", rsa.modulus, RSA_LIMBS); in main()
542 ret = handleSign(&buf, bufUsed, out, &rsa, verbose, bareData); in main()
544 ret = handleVerify(&buf, bufUsed, &rsa, verbose, bareData); in main()
546 ret = handleConvertKey(&buf, bufUsed, out, &rsa); in main()