Skip to content

Commit

Permalink
add checks and switch to x509v3_cache_extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel40791765 committed Mar 28, 2024
1 parent bac806d commit d56c5bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crypto/x509/x509_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <openssl/obj.h>
#include <openssl/x509.h>

#include "../x509v3/internal.h"
#include "internal.h"
#include "openssl/x509v3.h"

Expand Down Expand Up @@ -259,10 +260,14 @@ static int X509_SIG_INFO_get(const X509_SIG_INFO *sig_info, int *digest_nid,

int X509_get_signature_info(X509 *x509, int *digest_nid, int *pubkey_nid,
int *sec_bits, uint32_t *flags) {
if (!X509_check_purpose(x509, -1, -1)) {
if (x509 == NULL) {
OPENSSL_PUT_ERROR(X509, ERR_R_PASSED_NULL_PARAMETER);
}
if(!x509v3_cache_extensions(x509)) {
OPENSSL_PUT_ERROR(X509, X509_V_ERR_INVALID_PURPOSE);
return 0;
}

return X509_SIG_INFO_get(&x509->sig_info, digest_nid, pubkey_nid, sec_bits,
flags);
}
Expand Down
4 changes: 3 additions & 1 deletion crypto/x509v3/v3_purp.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ static int xp_cmp(const X509_PURPOSE *const *a, const X509_PURPOSE *const *b) {

// As much as I'd like to make X509_check_purpose use a "const" X509* I
// really can't because it does recalculate hashes and do other non-const
// things.
// things. If |id| is -1 it just calls |x509v3_cache_extensions| for its
// side-effect.
// Returns 1 on success, 0 if x does not allow purpose, -1 on (internal) error.
int X509_check_purpose(X509 *x, int id, int ca) {
int idx;
const X509_PURPOSE *pt;
Expand Down

0 comments on commit d56c5bd

Please sign in to comment.