+ cfgfatal_maybefile(f,loc,"rsa-private",
+ "error reading decryption key\n");
+ }
+ mpz_init(&d);
+ read_mpbin(&d,b,length);
+ free(b);
+ /* Read iqmp (inverse of q mod p) */
+ length=(keyfile_get_short(loc,f)+7)/8;
+ if (length>RSA_MAX_MODBYTES) {
+ cfgfatal(loc,"rsa-private","implausibly long (%ld)"
+ " iqmp auxiliary value\n", length);
+ }
+ b=safe_malloc(length,"rsapriv_apply");
+ if (fread(b,length,1,f)!=1) {
+ cfgfatal_maybefile(f,loc,"rsa-private",
+ "error reading decryption key\n");
+ }
+ mpz_init(&iqmp);
+ read_mpbin(&iqmp,b,length);
+ free(b);
+ /* Read q (the smaller of the two primes) */
+ length=(keyfile_get_short(loc,f)+7)/8;
+ if (length>RSA_MAX_MODBYTES) {
+ cfgfatal(loc,"rsa-private","implausibly long (%ld) q value\n",
+ length);
+ }
+ b=safe_malloc(length,"rsapriv_apply");
+ if (fread(b,length,1,f)!=1) {
+ cfgfatal_maybefile(f,loc,"rsa-private",
+ "error reading q value\n");
+ }
+ mpz_init(&st->q);
+ read_mpbin(&st->q,b,length);
+ free(b);
+ /* Read p (the larger of the two primes) */
+ length=(keyfile_get_short(loc,f)+7)/8;
+ if (length>RSA_MAX_MODBYTES) {
+ cfgfatal(loc,"rsa-private","implausibly long (%ld) p value\n",
+ length);
+ }
+ b=safe_malloc(length,"rsapriv_apply");
+ if (fread(b,length,1,f)!=1) {
+ cfgfatal_maybefile(f,loc,"rsa-private",
+ "error reading p value\n");