Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rsa_st definition is absent #1604

Closed
MChelik opened this issue Sep 20, 2016 · 6 comments
Closed

rsa_st definition is absent #1604

MChelik opened this issue Sep 20, 2016 · 6 comments

Comments

@MChelik
Copy link

@MChelik MChelik commented Sep 20, 2016

Dear OpenSSL developers,

When I use RSA struct, I get not defined error. Its definition in ossl_typ.h is like this:
typedef struct rsa_st RSA;
RSA is struct rsa_st but there is no body of it. I searched whole include/openssl for rsa_st but found nothing. Am I doing something wrong or there is lack of definition?
By the way ; I have same problem with EVP_PKEY too:
typedef struct evp_pkey_st EVP_PKEY;

P.S. I use OpenSSL 1.1.0 in VS2010.

Thank you

@mattcaswell

This comment has been minimized.

Copy link
Member

@mattcaswell mattcaswell commented Sep 20, 2016

One of the principle differences between OpenSSL 1.1.0 and previous versions is that many of the structures have now been made opaque. The biggest consequence of that is you cannot stack allocate the structures any more. So to create a new RSA object you must call RSA_new(). There are also various RSA_get*() and RSA_set*() functions that have been added to enable you to access the various members. Similarly with EVP_PKEY.

@MChelik

This comment has been minimized.

Copy link
Author

@MChelik MChelik commented Sep 20, 2016

Hmm... thank you for clarification. I changed my code like this to get N and E:

const BIGNUM *rsa_e, *rsa_n;
RSA_get0_key( rsa_key, &rsa_n, &rsa_e, NULL );

But I couldn't find any equivalent for getting public key algorithm:

int pubkey_algonid = OBJ_obj2nid(cert->cert_info->key->algor->algorithm);
if (pubkey_algonid == NID_rsaEncryption)
...

Do you know its equivalent in OpenSSL 1.1?

Thank you

@richsalz

This comment has been minimized.

Copy link
Contributor

@richsalz richsalz commented Sep 20, 2016

Retrieving the X509_PUBKEY structure using X509_get_X509_PUBKEY(), then
X509_PUBKEY_get0_param() should do the trick.

Please put questions on the openssl-users mailing list (https://mta.openssl.org for details)

@MChelik

This comment has been minimized.

Copy link
Author

@MChelik MChelik commented Sep 20, 2016

I did not test but I think it's correct ¯_(ツ)_/¯

X509_PUBKEY *public_key = X509_get_X509_PUBKEY( cert );
X509_ALGOR *algor;
X509_PUBKEY_get0_param( NULL, NULL, NULL, &algor, public_key );
const ASN1_OBJECT *algor_obj;
X509_ALGOR_get0( &algor_obj, NULL, NULL, algor );
int pubkey_algonid = OBJ_obj2nid( algor_obj );
@mattcaswell

This comment has been minimized.

Copy link
Member

@mattcaswell mattcaswell commented Sep 20, 2016

Looks ok - except you need to add error checking. Even easier though is (without error checking):

X509_PUBKEY *public_key = X509_get_X509_PUBKEY( cert );
const ASN1_OBJECT *algor_obj;
X509_PUBKEY_get0_param( &algor_obj, NULL, NULL, NULL public_key );
int pubkey_algonid = OBJ_obj2nid( algor_obj );
@MChelik

This comment has been minimized.

Copy link
Author

@MChelik MChelik commented Sep 21, 2016

Thank you very much Matt.
Have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.