Hello,
> How do i find it through the X509 struct ?
> X509 *myX509 = ....
> is this the field ?
> myX509->sig_alg->algorithm->nid
In general: myX509->sig_alg->algorithm object.
pkcs-1 OBJECT IDENTIFIER ::= {
iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1
}
sha256WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 11 }
which means: 1.2.840.113549.1.1.11
I've attached simple test code.
Best regards,
--
Marek Marcola <[EMAIL PROTECTED]>
#include <stdio.h>
#include <errno.h>
#include <openssl/x509.h>
#include <openssl/ssl.h>
int main()
{
X509 *x509 = NULL;
FILE *fp;
BIO *b;
char buf[80];
SSL_load_error_strings();
SSLeay_add_all_algorithms();
if ((fp = fopen("./1037.pem", "r")) == NULL) {
fprintf(stderr, "fopen: %s\n", strerror(errno));
goto err;
}
if ((x509 = PEM_read_X509(fp, NULL, NULL, NULL)) == NULL) {
ERR_print_errors_fp(stderr);
goto err;
}
/* first print */
if ((b = BIO_new(BIO_s_file())) == NULL) {
goto err;
}
BIO_set_fp(b, stdout, BIO_NOCLOSE);
BIO_puts(b, "1) Signature algorithm: ");
i2a_ASN1_OBJECT(b, x509->sig_alg->algorithm);
BIO_puts(b, "\n");
BIO_free(b);
/* second print */
i2t_ASN1_OBJECT(buf, sizeof(buf), x509->sig_alg->algorithm);
printf("2) Signature algorithm: %s\n", buf);
return (0);
err:
return (1);
}