Skip to content

Commit 6f1695d

Browse files
authored
Merge pull request #687 from botovq/x509_algor
Use X509_ALGOR_get0() accessor for X509_ALGOR
2 parents 050f0c6 + 812aeab commit 6f1695d

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

ext/openssl/ossl_ts.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ obj_to_asn1obj_i(VALUE obj)
152152
}
153153

154154
static VALUE
155-
get_asn1obj(ASN1_OBJECT *obj)
155+
get_asn1obj(const ASN1_OBJECT *obj)
156156
{
157157
BIO *out;
158158
VALUE ret;
@@ -236,11 +236,13 @@ ossl_ts_req_get_algorithm(VALUE self)
236236
TS_REQ *req;
237237
TS_MSG_IMPRINT *mi;
238238
X509_ALGOR *algor;
239+
const ASN1_OBJECT *obj;
239240

240241
GetTSRequest(self, req);
241242
mi = TS_REQ_get_msg_imprint(req);
242243
algor = TS_MSG_IMPRINT_get_algo(mi);
243-
return get_asn1obj(algor->algorithm);
244+
X509_ALGOR_get0(&obj, NULL, NULL, algor);
245+
return get_asn1obj(obj);
244246
}
245247

246248
/*
@@ -490,13 +492,15 @@ ossl_ts_req_to_der(VALUE self)
490492
TS_REQ *req;
491493
TS_MSG_IMPRINT *mi;
492494
X509_ALGOR *algo;
495+
const ASN1_OBJECT *obj;
493496
ASN1_OCTET_STRING *hashed_msg;
494497

495498
GetTSRequest(self, req);
496499
mi = TS_REQ_get_msg_imprint(req);
497500

498501
algo = TS_MSG_IMPRINT_get_algo(mi);
499-
if (OBJ_obj2nid(algo->algorithm) == NID_undef)
502+
X509_ALGOR_get0(&obj, NULL, NULL, algo);
503+
if (OBJ_obj2nid(obj) == NID_undef)
500504
ossl_raise(eTimestampError, "Message imprint missing algorithm");
501505

502506
hashed_msg = TS_MSG_IMPRINT_get_msg(mi);
@@ -969,11 +973,13 @@ ossl_ts_token_info_get_algorithm(VALUE self)
969973
TS_TST_INFO *info;
970974
TS_MSG_IMPRINT *mi;
971975
X509_ALGOR *algo;
976+
const ASN1_OBJECT *obj;
972977

973978
GetTSTokenInfo(self, info);
974979
mi = TS_TST_INFO_get_msg_imprint(info);
975980
algo = TS_MSG_IMPRINT_get_algo(mi);
976-
return get_asn1obj(algo->algorithm);
981+
X509_ALGOR_get0(&obj, NULL, NULL, algo);
982+
return get_asn1obj(obj);
977983
}
978984

979985
/*

ext/openssl/ossl_x509cert.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,15 @@ ossl_x509_get_signature_algorithm(VALUE self)
328328
{
329329
X509 *x509;
330330
BIO *out;
331+
const ASN1_OBJECT *obj;
331332
VALUE str;
332333

333334
GetX509(self, x509);
334335
out = BIO_new(BIO_s_mem());
335336
if (!out) ossl_raise(eX509CertError, NULL);
336337

337-
if (!i2a_ASN1_OBJECT(out, X509_get0_tbs_sigalg(x509)->algorithm)) {
338+
X509_ALGOR_get0(&obj, NULL, NULL, X509_get0_tbs_sigalg(x509));
339+
if (!i2a_ASN1_OBJECT(out, obj)) {
338340
BIO_free(out);
339341
ossl_raise(eX509CertError, NULL);
340342
}

ext/openssl/ossl_x509crl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,16 @@ ossl_x509crl_get_signature_algorithm(VALUE self)
169169
{
170170
X509_CRL *crl;
171171
const X509_ALGOR *alg;
172+
const ASN1_OBJECT *obj;
172173
BIO *out;
173174

174175
GetX509CRL(self, crl);
175176
if (!(out = BIO_new(BIO_s_mem()))) {
176177
ossl_raise(eX509CRLError, NULL);
177178
}
178179
X509_CRL_get0_signature(crl, NULL, &alg);
179-
if (!i2a_ASN1_OBJECT(out, alg->algorithm)) {
180+
X509_ALGOR_get0(&obj, NULL, NULL, alg);
181+
if (!i2a_ASN1_OBJECT(out, obj)) {
180182
BIO_free(out);
181183
ossl_raise(eX509CRLError, NULL);
182184
}

ext/openssl/ossl_x509req.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ ossl_x509req_get_signature_algorithm(VALUE self)
259259
{
260260
X509_REQ *req;
261261
const X509_ALGOR *alg;
262+
const ASN1_OBJECT *obj;
262263
BIO *out;
263264

264265
GetX509Req(self, req);
@@ -267,7 +268,8 @@ ossl_x509req_get_signature_algorithm(VALUE self)
267268
ossl_raise(eX509ReqError, NULL);
268269
}
269270
X509_REQ_get0_signature(req, NULL, &alg);
270-
if (!i2a_ASN1_OBJECT(out, alg->algorithm)) {
271+
X509_ALGOR_get0(&obj, NULL, NULL, alg);
272+
if (!i2a_ASN1_OBJECT(out, obj)) {
271273
BIO_free(out);
272274
ossl_raise(eX509ReqError, NULL);
273275
}

0 commit comments

Comments
 (0)