Skip to content

Commit 6f48f0d

Browse files
committed
Store fingerprint as raw byte array
1 parent a069bc0 commit 6f48f0d

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

ssl/crypto_misc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct _x509_ctx
7676
uint8_t sig_type;
7777
RSA_CTX *rsa_ctx;
7878
bigint *digest;
79-
bigint *fingerprint;
79+
uint8_t *fingerprint;
8080
struct _x509_ctx *next;
8181
};
8282

ssl/tls1.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1892,8 +1892,7 @@ EXP_FUNC int STDCALL ssl_match_fingerprint(const SSL *ssl, const uint8_t* fp)
18921892
uint8_t cert_fp[SHA1_SIZE];
18931893
X509_CTX* x509 = ssl->x509_ctx;
18941894

1895-
bi_export(x509->rsa_ctx->bi_ctx, x509->fingerprint, cert_fp, SHA1_SIZE);
1896-
return memcmp(cert_fp, fp, SHA1_SIZE);
1895+
return memcmp(x509->fingerprint, fp, SHA1_SIZE);
18971896
}
18981897

18991898
#endif /* CONFIG_SSL_CERT_VERIFICATION */

ssl/x509.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,11 @@ int x509_new(const uint8_t *cert, int *len, X509_CTX **ctx)
119119

120120
bi_ctx = x509_ctx->rsa_ctx->bi_ctx;
121121

122+
x509_ctx->fingerprint = malloc(SHA1_SIZE);
122123
SHA1_CTX sha_fp_ctx;
123-
uint8_t sha_fp_dgst[SHA1_SIZE];
124124
SHA1_Init(&sha_fp_ctx);
125125
SHA1_Update(&sha_fp_ctx, &cert[0], cert_size);
126-
SHA1_Final(sha_fp_dgst, &sha_fp_ctx);
127-
x509_ctx->fingerprint = bi_import(bi_ctx, sha_fp_dgst, SHA1_SIZE);
126+
SHA1_Final(x509_ctx->fingerprint, &sha_fp_ctx);
128127

129128
#ifdef CONFIG_SSL_CERT_VERIFICATION /* only care if doing verification */
130129
/* use the appropriate signature algorithm (SHA1/MD5/MD2) */
@@ -254,7 +253,7 @@ void x509_free(X509_CTX *x509_ctx)
254253

255254
if (x509_ctx->fingerprint)
256255
{
257-
bi_free(x509_ctx->rsa_ctx->bi_ctx, x509_ctx->fingerprint);
256+
free(x509_ctx->fingerprint);
258257
}
259258

260259
if (x509_ctx->subject_alt_dnsnames)

0 commit comments

Comments
 (0)