Project

General

Profile

Bug #4421 » fix_rsa_pub_encoding.diff

MartinBosslet (Martin Bosslet), 02/22/2011 08:18 AM

View differences:

ruby/ext/openssl/ossl_pkey_rsa.c (working copy)
rsa = PEM_read_bio_RSAPrivateKey(in, NULL, ossl_pem_passwd_cb, passwd);
if (!rsa) {
(void)BIO_reset(in);
rsa = PEM_read_bio_RSAPublicKey(in, NULL, NULL, NULL);
rsa = PEM_read_bio_RSA_PUBKEY(in, NULL, NULL, NULL);
}
if (!rsa) {
(void)BIO_reset(in);
rsa = PEM_read_bio_RSA_PUBKEY(in, NULL, NULL, NULL);
rsa = d2i_RSAPrivateKey_bio(in, NULL);
}
if (!rsa) {
(void)BIO_reset(in);
rsa = d2i_RSAPrivateKey_bio(in, NULL);
rsa = d2i_RSA_PUBKEY_bio(in, NULL);
}
if (!rsa) {
(void)BIO_reset(in);
rsa = d2i_RSAPublicKey_bio(in, NULL);
rsa = PEM_read_bio_RSAPublicKey(in, NULL, NULL, NULL);
}
if (!rsa) {
(void)BIO_reset(in);
rsa = d2i_RSA_PUBKEY_bio(in, NULL);
rsa = d2i_RSAPublicKey_bio(in, NULL);
}
BIO_free(in);
if (!rsa) ossl_raise(eRSAError, "Neither PUB key nor PRIV key:");
......
ossl_raise(eRSAError, NULL);
}
} else {
if (!PEM_write_bio_RSAPublicKey(out, pkey->pkey.rsa)) {
if (!PEM_write_bio_RSA_PUBKEY(out, pkey->pkey.rsa)) {
BIO_free(out);
ossl_raise(eRSAError, NULL);
}
......
if(RSA_HAS_PRIVATE(pkey->pkey.rsa))
i2d_func = i2d_RSAPrivateKey;
else
i2d_func = i2d_RSAPublicKey;
i2d_func = (int (*)(const RSA*, unsigned char**))i2d_RSA_PUBKEY;
if((len = i2d_func(pkey->pkey.rsa, NULL)) <= 0)
ossl_raise(eRSAError, NULL);
str = rb_str_new(0, len);
(1-1/2)