Home | History | Annotate | Download | only in pem

Lines Matching defs:rsa

68 #include <openssl/rsa.h>
114 /* Convert private key blob to EVP_PKEY: RSA and DSA keys supported */
375 RSA *rsa = NULL;
379 rsa = RSA_new();
381 if (!rsa || !ret)
383 rsa->e = BN_new();
384 if (!rsa->e)
386 if (!BN_set_word(rsa->e, read_ledword(&p)))
388 if (!read_lebn(&p, nbyte, &rsa->n))
392 if (!read_lebn(&p, hnbyte, &rsa->p))
394 if (!read_lebn(&p, hnbyte, &rsa->q))
396 if (!read_lebn(&p, hnbyte, &rsa->dmp1))
398 if (!read_lebn(&p, hnbyte, &rsa->dmq1))
400 if (!read_lebn(&p, hnbyte, &rsa->iqmp))
402 if (!read_lebn(&p, nbyte, &rsa->d))
406 EVP_PKEY_set1_RSA(ret, rsa);
407 RSA_free(rsa);
412 if (rsa)
413 RSA_free(rsa);
478 static int check_bitlen_rsa(RSA *rsa, int ispub, unsigned int *magic);
481 static void write_rsa(unsigned char **out, RSA *rsa, int ispub);
496 bitlen = check_bitlen_rsa(pk->pkey.rsa, ispub, &magic);
530 write_rsa(&p, pk->pkey.rsa, ispub);
576 static int check_bitlen_rsa(RSA *rsa, int ispub, unsigned int *pmagic)
579 if (BN_num_bits(rsa->e) > 32)
581 bitlen = BN_num_bits(rsa->n);
582 nbyte = BN_num_bytes(rsa->n);
583 hnbyte = (BN_num_bits(rsa->n) + 15) >> 4;
595 if (BN_num_bytes(rsa->d) > nbyte)
597 if ((BN_num_bytes(rsa->iqmp) > hnbyte)
598 || (BN_num_bytes(rsa->p) > hnbyte)
599 || (BN_num_bytes(rsa->q) > hnbyte)
600 || (BN_num_bytes(rsa->dmp1) > hnbyte)
601 || (BN_num_bytes(rsa->dmq1) > hnbyte))
611 static void write_rsa(unsigned char **out, RSA *rsa, int ispub)
614 nbyte = BN_num_bytes(rsa->n);
615 hnbyte = (BN_num_bits(rsa->n) + 15) >> 4;
616 write_lebn(out, rsa->e, 4);
617 write_lebn(out, rsa->n, -1);
620 write_lebn(out, rsa->p, hnbyte);
621 write_lebn(out, rsa->q, hnbyte);
622 write_lebn(out, rsa->dmp1, hnbyte);
623 write_lebn(out, rsa->dmq1, hnbyte);
624 write_lebn(out, rsa->iqmp, hnbyte);
625 write_lebn(out, rsa->d, nbyte);