| 158 |
158 |
rsa = PEM_read_bio_RSAPrivateKey(in, NULL, ossl_pem_passwd_cb, passwd);
|
| 159 |
159 |
if (!rsa) {
|
| 160 |
160 |
(void)BIO_reset(in);
|
| 161 |
|
rsa = PEM_read_bio_RSAPublicKey(in, NULL, NULL, NULL);
|
|
161 |
rsa = PEM_read_bio_RSA_PUBKEY(in, NULL, NULL, NULL);
|
| 162 |
162 |
}
|
| 163 |
163 |
if (!rsa) {
|
| 164 |
164 |
(void)BIO_reset(in);
|
| 165 |
|
rsa = PEM_read_bio_RSA_PUBKEY(in, NULL, NULL, NULL);
|
|
165 |
rsa = d2i_RSAPrivateKey_bio(in, NULL);
|
| 166 |
166 |
}
|
| 167 |
167 |
if (!rsa) {
|
| 168 |
168 |
(void)BIO_reset(in);
|
| 169 |
|
rsa = d2i_RSAPrivateKey_bio(in, NULL);
|
|
169 |
rsa = d2i_RSA_PUBKEY_bio(in, NULL);
|
| 170 |
170 |
}
|
| 171 |
171 |
if (!rsa) {
|
| 172 |
172 |
(void)BIO_reset(in);
|
| 173 |
|
rsa = d2i_RSAPublicKey_bio(in, NULL);
|
|
173 |
rsa = PEM_read_bio_RSAPublicKey(in, NULL, NULL, NULL);
|
| 174 |
174 |
}
|
| 175 |
175 |
if (!rsa) {
|
| 176 |
176 |
(void)BIO_reset(in);
|
| 177 |
|
rsa = d2i_RSA_PUBKEY_bio(in, NULL);
|
|
177 |
rsa = d2i_RSAPublicKey_bio(in, NULL);
|
| 178 |
178 |
}
|
| 179 |
179 |
BIO_free(in);
|
| 180 |
180 |
if (!rsa) ossl_raise(eRSAError, "Neither PUB key nor PRIV key:");
|
| ... | ... | |
| 260 |
260 |
ossl_raise(eRSAError, NULL);
|
| 261 |
261 |
}
|
| 262 |
262 |
} else {
|
| 263 |
|
if (!PEM_write_bio_RSAPublicKey(out, pkey->pkey.rsa)) {
|
|
263 |
if (!PEM_write_bio_RSA_PUBKEY(out, pkey->pkey.rsa)) {
|
| 264 |
264 |
BIO_free(out);
|
| 265 |
265 |
ossl_raise(eRSAError, NULL);
|
| 266 |
266 |
}
|
| ... | ... | |
| 289 |
289 |
if(RSA_HAS_PRIVATE(pkey->pkey.rsa))
|
| 290 |
290 |
i2d_func = i2d_RSAPrivateKey;
|
| 291 |
291 |
else
|
| 292 |
|
i2d_func = i2d_RSAPublicKey;
|
|
292 |
i2d_func = (int (*)(const RSA*, unsigned char**))i2d_RSA_PUBKEY;
|
| 293 |
293 |
if((len = i2d_func(pkey->pkey.rsa, NULL)) <= 0)
|
| 294 |
294 |
ossl_raise(eRSAError, NULL);
|
| 295 |
295 |
str = rb_str_new(0, len);
|