diff options
Diffstat (limited to 'board/cr50/dcrypto/x509.c')
-rw-r--r-- | board/cr50/dcrypto/x509.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/board/cr50/dcrypto/x509.c b/board/cr50/dcrypto/x509.c index 4417f1701b..1ffefceb94 100644 --- a/board/cr50/dcrypto/x509.c +++ b/board/cr50/dcrypto/x509.c @@ -421,15 +421,16 @@ static void add_common_name(struct asn1 *ctx, const char *cname) SEQ_END(*ctx); } -int DCRYPTO_x509_gen_u2f_cert_name(const p256_int *d, const p256_int *pk_x, - const p256_int *pk_y, const p256_int *serial, - const char *name, uint8_t *cert, const int n) +size_t DCRYPTO_x509_gen_u2f_cert_name(const p256_int *d, const p256_int *pk_x, + const p256_int *pk_y, + const p256_int *serial, const char *name, + uint8_t *cert, const size_t n) { struct asn1 ctx = {cert, 0}; struct sha256_ctx sha; p256_int h, r, s; struct drbg_ctx drbg; - int result; + enum dcrypto_result result; SEQ_START(ctx, V_SEQ, SEQ_LARGE) { /* outer seq */ /* @@ -519,9 +520,9 @@ int DCRYPTO_x509_gen_u2f_cert_name(const p256_int *d, const p256_int *pk_x, SHA256_update(&sha, body, (ctx.p + ctx.n) - body); p256_from_bin(SHA256_final(&sha)->b8, &h); hmac_drbg_init_rfc6979(&drbg, d, &h); - result = dcrypto_p256_ecdsa_sign(&drbg, d, &h, &r, &s) - DCRYPTO_OK; + result = dcrypto_p256_ecdsa_sign(&drbg, d, &h, &r, &s); drbg_exit(&drbg); - if (result) + if (result != DCRYPTO_OK) return 0; /* Append X509 signature */ @@ -539,9 +540,9 @@ int DCRYPTO_x509_gen_u2f_cert_name(const p256_int *d, const p256_int *pk_x, return ctx.n; } -int DCRYPTO_x509_gen_u2f_cert(const p256_int *d, const p256_int *pk_x, - const p256_int *pk_y, const p256_int *serial, - uint8_t *cert, const int n) +size_t DCRYPTO_x509_gen_u2f_cert(const p256_int *d, const p256_int *pk_x, + const p256_int *pk_y, const p256_int *serial, + uint8_t *cert, const size_t n) { return DCRYPTO_x509_gen_u2f_cert_name(d, pk_x, pk_y, serial, serial ? STRINGIFY(BOARD) : "U2F", |