|
| | FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) |
| | FILE_SECBOOT (PERMITTED) |
| static int | ecdsa_parse_key (struct ecdsa_key *key, const struct asn1_cursor *raw) |
| | Parse ECDSA key.
|
| static int | ecdsa_parse_signature (struct ecdsa_context *ctx, bigint_element_t *rs0, const struct asn1_cursor *raw) |
| | Parse ECDSA signature value.
|
| static int | ecdsa_prepend_signature (struct ecdsa_context *ctx, bigint_element_t *rs0, struct asn1_builder *builder) |
| | Prepend ECDSA signature value.
|
| static int | ecdsa_alloc (struct ecdsa_context *ctx) |
| | Allocate ECDSA context dynamic storage.
|
| static void | ecdsa_free (struct ecdsa_context *ctx) |
| | Free ECDSA context dynamic storage.
|
| static void | ecdsa_init_values (struct ecdsa_context *ctx, struct digest_algorithm *digest, const void *value) |
| | Initialise ECDSA values.
|
| static int | ecdsa_init (struct ecdsa_context *ctx, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value) |
| | Initialise ECDSA context.
|
| static void | ecdsa_invert (struct ecdsa_context *ctx, bigint_element_t *val0) |
| | Invert ECDSA value.
|
| static int | ecdsa_sign_rs (struct ecdsa_context *ctx) |
| | Generate ECDSA "r" and "s" values.
|
| static int | ecdsa_verify_rs (struct ecdsa_context *ctx) |
| | Verify ECDSA "r" and "s" values.
|
| static int | ecdsa_encrypt (const struct asn1_cursor *key __unused, const struct asn1_cursor *plaintext __unused, struct asn1_builder *ciphertext __unused) |
| | Encrypt using ECDSA.
|
| static int | ecdsa_decrypt (const struct asn1_cursor *key __unused, const struct asn1_cursor *ciphertext __unused, struct asn1_builder *plaintext __unused) |
| | Decrypt using ECDSA.
|
| static int | ecdsa_sign (const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, struct asn1_builder *signature) |
| | Sign digest value using ECDSA.
|
| static int | ecdsa_verify (const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, const struct asn1_cursor *signature) |
| | Verify signed digest using ECDSA.
|
| static int | ecdsa_match (const struct asn1_cursor *private_key, const struct asn1_cursor *public_key) |
| | Check for matching ECDSA public/private key pair.
|
Elliptic curve digital signature algorithm (ECDSA)
The elliptic curve public key format is documented in RFC 5480. The original private key format is documented in RFC 5915, and the generic container PKCS#8 format documented in RFC 5208.
Definition in file ecdsa.c.
Parse ECDSA key.
- Parameters
-
| key | ECDSA key |
| raw | ASN.1 cursor |
- Return values
-
Definition at line 141 of file ecdsa.c.
142 {
148 int is_private;
150
151
152 memcpy ( &cursor,
raw,
sizeof ( cursor ) );
156
157
159
160
161 is_private = 1;
162
163
165
166
168
169
170 DBGC (
key,
"ECDSA %p is in PKCS#8 format\n",
key );
171
172
173 memcpy ( &curve, &cursor,
sizeof ( curve ) );
175
176
178
179
181
182
184 }
185
186
187 memcpy ( &
private, &cursor,
sizeof (
private ) );
190
191
193 memcpy ( &curve, &cursor,
sizeof ( curve ) );
196 }
197
198
200
201 } else {
202
203
204 is_private = 0;
205
206
207 memcpy ( &curve, &cursor,
sizeof ( curve ) );
209 }
210
211
213
214
217 DBGC (
key,
"ECDSA %p unknown curve: %s\n",
221 }
224 key->curve->name, ( is_private ?
"private" :
"public" ) );
225
226
227 if ( cursor.len != ( sizeof ( *compression ) +
228 key->curve->pointsize ) ) {
229 DBGC (
key,
"ECDSA %p invalid public key length %zd\n",
233 }
234
235
236 compression = cursor.data;
238 DBGC (
key,
"ECDSA %p invalid compression %#02x\n",
242 }
243
244
245 key->public = ( cursor.data +
sizeof ( *compression ) );
246 DBGC (
key,
"ECDSA %p public curve point:\n",
key );
248
249
251 DBGC (
key,
"ECDSA %p public curve point is infinity\n",
key );
253 }
254
255
256 if ( is_private ) {
257
258
259 if (
private.
len !=
key->curve->keysize ) {
260 DBGC (
key,
"ECDSA %p invalid private key length "
261 "%zd\n",
key,
private.
len );
264 }
265
266
267 key->private =
private.data;
268 DBGC (
key,
"ECDSA %p private multiplier:\n",
key );
270
271 } else {
272
273
275 }
276
277 return 0;
278}
#define NULL
NULL pointer (VOID *)
union @162305117151260234136356364136041353210355154177 key
Sense key.
struct arbelprm_rc_send_wqe rc
int asn1_skip_any(struct asn1_cursor *cursor)
Skip ASN.1 object of any type.
int asn1_curve_algorithm(const struct asn1_cursor *cursor, struct asn1_algorithm *wrapper, struct asn1_algorithm **algorithm)
Parse ASN.1 OID-identified elliptic curve algorithm.
int asn1_enter(struct asn1_cursor *cursor, unsigned int type)
Enter ASN.1 object.
int asn1_enter_any(struct asn1_cursor *cursor)
Enter ASN.1 object of any type.
int asn1_skip(struct asn1_cursor *cursor, unsigned int type)
Skip ASN.1 object.
int asn1_enter_bits(struct asn1_cursor *cursor, unsigned int *unused)
Enter ASN.1 bit string.
#define ASN1_INTEGER
ASN.1 integer.
#define ASN1_EXPLICIT_TAG(number)
ASN.1 explicit tag.
static void asn1_invalidate_cursor(struct asn1_cursor *cursor)
Invalidate ASN.1 object cursor.
#define ASN1_SEQUENCE
ASN.1 sequence.
#define ASN1_OCTET_STRING
ASN.1 octet string.
static unsigned int asn1_type(const struct asn1_cursor *cursor)
Extract ASN.1 type.
#define EINVAL_COMPRESSION
#define ECDSA_UNCOMPRESSED
Uncompressed curve point.
u16 algorithm
Authentication algorithm (Open System or Shared Key)
static int elliptic_is_infinity(struct elliptic_curve *curve, const void *point)
void * memcpy(void *dest, const void *src, size_t len) __nonnull
char * strerror(int errno)
Retrieve string representation of error number.
An ASN.1 OID-identified algorithm.
References algorithm, asn1_curve_algorithm(), asn1_enter(), asn1_enter_any(), asn1_enter_bits(), ASN1_EXPLICIT_TAG, ASN1_INTEGER, asn1_invalidate_cursor(), ASN1_OCTET_STRING, ASN1_SEQUENCE, asn1_skip(), asn1_skip_any(), asn1_type(), asn1_cursor::data, DBGC, DBGC_HDA, ECDSA_UNCOMPRESSED, EINVAL_COMPRESSION, EINVAL_INFINITY, EINVAL_KEYSIZE, EINVAL_POINTSIZE, elliptic_is_infinity(), key, asn1_cursor::len, len, memcpy(), NULL, raw, rc, and strerror().
Referenced by ecdsa_init(), and ecdsa_match().
Parse ECDSA signature value.
- Parameters
-
| ctx | ECDSA context |
| rs0 | Element 0 of signature "r" or "s" value |
| raw | ASN.1 cursor |
- Return values
-
Definition at line 288 of file ecdsa.c.
290 {
294 ( (
void * )
ctx->modulus0 );
296 ( ( void * ) rs0 );
299
300
301 memcpy ( &cursor,
raw,
sizeof ( cursor ) );
303 DBGC (
ctx,
"ECDSA %p invalid integer:\n",
ctx );
306 }
307
308
310 DBGC (
ctx,
"ECDSA %p invalid signature value:\n",
ctx );
313 }
315
316
318 DBGC (
ctx,
"ECDSA %p out-of-range signature value:\n",
ctx );
321 }
322
323 return 0;
324}
struct golan_eq_context ctx
int asn1_enter_unsigned(struct asn1_cursor *cursor)
Enter ASN.1 unsigned integer.
uint16_t size
Buffer size.
#define ERANGE
Result too large.
#define bigint_is_geq(value, reference)
Compare big integers.
#define bigint_is_zero(value)
Test if big integer is equal to zero.
#define bigint_t(size)
Define a big-integer type.
#define bigint_init(value, data, len)
Initialise big integer.
u16 keysize
Length of encryption key to be used, network byte order.
References __attribute__, asn1_enter_unsigned(), bigint_init, bigint_is_geq, bigint_is_zero, bigint_t, ctx, asn1_cursor::data, DBGC, DBGC_HDA, EINVAL_KEYSIZE, ERANGE, keysize, asn1_cursor::len, memcpy(), raw, rc, and size.
Referenced by ecdsa_verify().
Prepend ECDSA signature value.
- Parameters
-
| ctx | ECDSA context |
| rs0 | Element 0 of signature "r" or "s" value |
| builder | ASN.1 builder |
- Return values
-
Definition at line 334 of file ecdsa.c.
336 {
340 ( ( void * ) rs0 );
345
346
347 buf[0] = 0;
349
350
352 len =
sizeof ( buf );
353 while ( (
len > 1 ) && (
data[0] == 0 ) && (
data[1] < 0x80 ) ) {
356 }
357
358
361
362 return 0;
363}
int asn1_prepend(struct asn1_builder *builder, unsigned int type, const void *data, size_t len)
Prepend data to ASN.1 builder.
uint8_t data[48]
Additional event data.
#define bigint_done(value, out, len)
Finalise big integer.
References __attribute__, ASN1_INTEGER, asn1_prepend(), bigint_done, bigint_t, ctx, data, keysize, len, rc, and size.
Referenced by ecdsa_sign().
Allocate ECDSA context dynamic storage.
- Parameters
-
- Return values
-
Definition at line 371 of file ecdsa.c.
371 {
377 struct {
391 struct hmac_drbg_state drbg;
392 } *dynamic;
393
394
395 dynamic =
malloc (
sizeof ( *dynamic ) );
396 if ( ! dynamic )
398
399
401 ctx->dynamic = dynamic;
402 ctx->modulus0 = dynamic->modulus.element;
403 ctx->fermat0 = dynamic->fermat.element;
404 ctx->square0 = dynamic->square.element;
405 ctx->one0 = dynamic->one.element;
406 ctx->z0 = dynamic->z.element;
407 ctx->k0 = dynamic->k.element;
408 ctx->r0 = dynamic->r.element;
409 ctx->s0 = dynamic->s.element;
410 ctx->temp0 = dynamic->temp.element;
411 ctx->product0 = dynamic->product.element;
412 ctx->point1 = dynamic->point1;
413 ctx->point2 = dynamic->point2;
414 ctx->scalar = dynamic->scalar;
415 ctx->drbg = &dynamic->drbg;
416
417 return 0;
418}
#define ENOMEM
Not enough space.
#define bigint_required_size(len)
Determine number of elements required for a big-integer type.
uint8_t product
Product string.
void * malloc(size_t size)
Allocate memory.
static const uint8_t r[3][4]
MD4 shift amounts.
static const uint32_t k[64]
MD5 constants.
size_t keysize
Scalar (and private key) size.
size_t pointsize
Point (and public key) size.
References bigint_required_size, bigint_t, ctx, ENOMEM, k, elliptic_curve::keysize, keysize, malloc(), elliptic_curve::pointsize, product, r, and size.
Referenced by ecdsa_init().
Initialise ECDSA values.
- Parameters
-
| ctx | ECDSA context |
| digest | Digest algorithm |
| value | Digest value |
Definition at line 438 of file ecdsa.c.
440 {
444 ( (
void * )
ctx->modulus0 );
446 ( (
void * )
ctx->fermat0 );
448 ( (
void * )
ctx->square0 );
450 ( (
void * )
ctx->one0 );
452 ( (
void * )
ctx->z0 );
454 ( (
void * )
ctx->product0 );
455 static const uint8_t two_raw[] = { 2 };
456 size_t zlen;
457
458
461
462
464 bigint_init ( square, two_raw,
sizeof ( two_raw ) );
466
467
469 DBGC2 (
ctx,
"ECDSA %p R^2 = %s mod N\n",
471
472
475 DBGC2 (
ctx,
"ECDSA %p R = %s mod N\n",
477
478
479 ctx->digest = digest;
480 zlen =
ctx->key.curve->keysize;
485 DBGC2 (
ctx,
"ECDSA %p z = %s (%s)\n",
487}
pseudo_bit_t value[0x00020]
#define bigint_grow(source, dest)
Grow big integer.
#define bigint_reduce(modulus, result)
Reduce big integer R^2 modulo N.
#define bigint_subtract(subtrahend, value)
Subtract big integers.
#define bigint_montgomery(modulus, value, result)
Perform classic Montgomery reduction (REDC) of a big integer.
#define bigint_copy(source, dest)
Copy big integer.
#define bigint_ntoa(value)
Transcribe big integer (for debugging)
size_t digestsize
Digest size.
const char * name
Algorithm name.
const void * order
Order of the generator (if prime)
References __attribute__, bigint_copy, bigint_grow, bigint_init, bigint_montgomery, bigint_ntoa, bigint_reduce, bigint_subtract, bigint_t, ctx, DBGC2, digest_algorithm::digestsize, elliptic_curve::keysize, digest_algorithm::name, elliptic_curve::order, product, size, and value.
Referenced by ecdsa_init().
Initialise ECDSA context.
- Parameters
-
| ctx | ECDSA context |
| key | Key |
| digest | Digest algorithm |
| value | Digest value |
- Return values
-
Definition at line 498 of file ecdsa.c.
501 {
503
504
506 goto err_parse;
507
508
510 goto err_alloc;
511
512
514
515 return 0;
516
518 err_alloc:
519 err_parse:
521}
static int ecdsa_parse_key(struct ecdsa_key *key, const struct asn1_cursor *raw)
Parse ECDSA key.
static void ecdsa_init_values(struct ecdsa_context *ctx, struct digest_algorithm *digest, const void *value)
Initialise ECDSA values.
static int ecdsa_alloc(struct ecdsa_context *ctx)
Allocate ECDSA context dynamic storage.
static void ecdsa_free(struct ecdsa_context *ctx)
Free ECDSA context dynamic storage.
References ctx, ecdsa_alloc(), ecdsa_free(), ecdsa_init_values(), ecdsa_parse_key(), key, rc, and value.
Referenced by ecdsa_sign(), and ecdsa_verify().
Invert ECDSA value.
- Parameters
-
| ctx | ECDSA context |
| val0 | Element 0 of value to invert |
Definition at line 529 of file ecdsa.c.
530 {
533 ( (
void * )
ctx->modulus0 );
535 ( (
void * )
ctx->fermat0 );
537 ( (
void * )
ctx->square0 );
539 ( (
void * )
ctx->one0 );
541 ( (
void * )
ctx->temp0 );
543 ( (
void * )
ctx->product0 );
545 ( ( void * ) val0 );
546
547
550
551
555}
void bigint_mod_exp_ladder(const bigint_element_t *multiplier0, bigint_element_t *result0, unsigned int size, const void *ctx, void *tmp)
Perform modular multiplication as part of a Montgomery ladder.
#define bigint_ladder(result, multiple, exponent, op, ctx, tmp)
Perform generalised exponentiation via a Montgomery ladder.
#define bigint_multiply(multiplicand, multiplier, result)
Multiply big integers.
References __attribute__, bigint_copy, bigint_ladder, bigint_mod_exp_ladder(), bigint_montgomery, bigint_multiply, bigint_t, ctx, product, size, and val.
Referenced by ecdsa_sign_rs(), and ecdsa_verify_rs().
Generate ECDSA "r" and "s" values.
- Parameters
-
| ctx | ECDSA context |
| sig | Signature |
- Return values
-
Definition at line 564 of file ecdsa.c.
564 {
571 ( (
void * )
ctx->modulus0 );
573 ( (
void * )
ctx->square0 );
575 ( (
void * )
ctx->one0 );
577 ( (
void * )
ctx->z0 );
579 ( (
void * )
ctx->k0 );
581 ( (
void * )
ctx->r0 );
583 ( (
void * )
ctx->s0 );
585 ( (
void * )
ctx->temp0 );
587 ( (
void * )
ctx->product0 );
589 ( ( void * ) temp );
590 void *point1 =
ctx->point1;
591 void *scalar =
ctx->scalar;
593
594
595 while ( 1 ) {
596
597
600 DBGC (
ctx,
"ECDSA %p could not generate: %s\n",
603 }
604
605
610 continue;
612 continue;
613
614
617 DBGC2 (
ctx,
"ECDSA %p x1 = %s mod N\n",
619
620
625
626
628 continue;
629
630
632 DBGC2 (
ctx,
"ECDSA %p (k^-1)R = %s mod N\n",
634
635
643 DBGC2 (
ctx,
"ECDSA %p r*dA = %s mod N\n",
645
646
648 DBGC2 (
ctx,
"ECDSA %p z+r*dA = %s mod N\n",
654
655
657 continue;
658
659 return 0;
660 }
661}
static void ecdsa_invert(struct ecdsa_context *ctx, bigint_element_t *val0)
Invert ECDSA value.
int hmac_drbg_generate(struct digest_algorithm *hash, struct hmac_drbg_state *state, const void *additional, size_t additional_len, void *data, size_t len)
Generate pseudorandom bits using HMAC_DRBG.
#define bigint_add(addend, value)
Add big integers.
static int elliptic_multiply(struct elliptic_curve *curve, const void *base, const void *scalar, void *result)
A message digest algorithm.
const void * base
Generator base point.
References __attribute__, elliptic_curve::base, bigint_add, bigint_init, bigint_is_geq, bigint_is_zero, bigint_montgomery, bigint_multiply, bigint_ntoa, bigint_t, ctx, DBGC, DBGC2, ecdsa_invert(), elliptic_multiply(), hmac_drbg_generate(), k, elliptic_curve::keysize, keysize, NULL, elliptic_curve::pointsize, product, r, rc, size, and strerror().
Referenced by ecdsa_sign().
Verify ECDSA "r" and "s" values.
- Parameters
-
| ctx | ECDSA context |
| sig | Signature |
- Return values
-
Definition at line 670 of file ecdsa.c.
670 {
674 const void *
public =
ctx->key.public;
677 ( (
void * )
ctx->modulus0 );
679 ( (
void * )
ctx->one0 );
681 ( (
void * )
ctx->z0 );
683 ( (
void * )
ctx->r0 );
685 ( (
void * )
ctx->s0 );
687 ( (
void * )
ctx->temp0 );
689 ( (
void * )
ctx->product0 );
691 ( ( void * ) temp );
693 ( ( void * ) temp );
695 ( ( void * ) temp );
696 void *point1 =
ctx->point1;
697 void *point2 =
ctx->point2;
698 void *scalar =
ctx->scalar;
699 int valid;
701
704
705
708
709
712 DBGC2 (
ctx,
"ECDSA %p u1 = %s mod N\n",
715
716
718 point1 ) ) != 0 ) {
719 DBGC (
ctx,
"ECDSA %p could not calculate u1*G: %s\n",
722 }
723
724
728 DBGC2 (
ctx,
"ECDSA %p u2 = %s mod N\n",
730
731
733 point2 ) ) != 0 ) {
734 DBGC (
ctx,
"ECDSA %p could not calculate u2*Qa: %s\n",
737 }
738
739
740 if ( (
rc =
elliptic_add ( curve, point1, point2, point1 ) ) != 0 ) {
741 DBGC (
ctx,
"ECDSA %p could not calculate u1*G+u2*Qa: %s\n",
744 }
745
746
748 DBGC (
ctx,
"ECDSA %p result is point at infinity\n",
ctx );
750 }
751
752
758
759
762 DBGC2 (
ctx,
"ECDSA %p signature is%s valid\n",
763 ctx, ( valid ?
"" :
" not" ) );
764
766}
#define EINVAL
Invalid argument.
static int elliptic_add(struct elliptic_curve *curve, const void *addend, const void *augend, void *result)
References __attribute__, elliptic_curve::base, bigint_done, bigint_init, bigint_is_zero, bigint_montgomery, bigint_multiply, bigint_ntoa, bigint_subtract, bigint_t, ctx, DBGC, DBGC2, ecdsa_invert(), EINVAL, EINVAL_SIGNATURE, elliptic_add(), elliptic_is_infinity(), elliptic_multiply(), elliptic_curve::keysize, keysize, elliptic_curve::pointsize, product, r, rc, size, and strerror().
Referenced by ecdsa_verify().
Sign digest value using ECDSA.
- Parameters
-
| key | Key |
| digest | Digest algorithm |
| value | Digest value |
| signature | Signature |
- Return values
-
Definition at line 809 of file ecdsa.c.
811 {
814
815
817 goto err_init;
818
819
820 if ( !
ctx.key.private ) {
822 goto err_no_key;
823 }
824
825
828
829
831 goto err_signature;
832
833
835 goto err_s;
837 goto err_r;
839 goto err_wrap;
840
841
843
844 return 0;
845
846 err_wrap:
847 err_r:
848 err_s:
849 err_signature:
850 err_no_key:
852 err_init:
854}
u8 signature
CPU signature.
int asn1_wrap(struct asn1_builder *builder, unsigned int type)
Wrap ASN.1 builder.
static int ecdsa_sign_rs(struct ecdsa_context *ctx)
Generate ECDSA "r" and "s" values.
static int ecdsa_prepend_signature(struct ecdsa_context *ctx, bigint_element_t *rs0, struct asn1_builder *builder)
Prepend ECDSA signature value.
static int ecdsa_init(struct ecdsa_context *ctx, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value)
Initialise ECDSA context.
void hmac_drbg_instantiate(struct digest_algorithm *hash, struct hmac_drbg_state *state, const void *entropy, size_t entropy_len, const void *personal, size_t personal_len)
Instantiate HMAC_DRBG.
struct digest_algorithm * digest
Digest algorithm.
References ASN1_SEQUENCE, asn1_wrap(), ctx, ecdsa_context::digest, ecdsa_free(), ecdsa_init(), ecdsa_prepend_signature(), ecdsa_sign_rs(), ENOTTY, hmac_drbg_instantiate(), key, rc, signature, and value.
Verify signed digest using ECDSA.
- Parameters
-
| key | Key |
| digest | Digest algorithm |
| value | Digest value |
| signature | Signature |
- Return values
-
Definition at line 865 of file ecdsa.c.
867 {
871
872
874 goto err_init;
875
876
879
880
882 goto err_r;
885 goto err_s;
886
887
889 goto err_verify;
890
891
893
894 return 0;
895
896 err_verify:
897 err_s:
898 err_r:
900 err_init:
902}
static int ecdsa_verify_rs(struct ecdsa_context *ctx)
Verify ECDSA "r" and "s" values.
static int ecdsa_parse_signature(struct ecdsa_context *ctx, bigint_element_t *rs0, const struct asn1_cursor *raw)
Parse ECDSA signature value.
References asn1_enter(), ASN1_SEQUENCE, asn1_skip_any(), ctx, ecdsa_free(), ecdsa_init(), ecdsa_parse_signature(), ecdsa_verify_rs(), key, memcpy(), rc, signature, and value.
Initial value:= {
.name = "ecdsa",
}
static int ecdsa_encrypt(const struct asn1_cursor *key __unused, const struct asn1_cursor *plaintext __unused, struct asn1_builder *ciphertext __unused)
Encrypt using ECDSA.
static int ecdsa_sign(const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, struct asn1_builder *signature)
Sign digest value using ECDSA.
static int ecdsa_verify(const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, const struct asn1_cursor *signature)
Verify signed digest using ECDSA.
static int ecdsa_match(const struct asn1_cursor *private_key, const struct asn1_cursor *public_key)
Check for matching ECDSA public/private key pair.
static int ecdsa_decrypt(const struct asn1_cursor *key __unused, const struct asn1_cursor *ciphertext __unused, struct asn1_builder *plaintext __unused)
Decrypt using ECDSA.
ECDSA public-key algorithm.
Definition at line 937 of file ecdsa.c.
937 {
938 .name = "ecdsa",
944};
Referenced by __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), PUBKEY_SIGN_TEST(), PUBKEY_SIGN_TEST(), PUBKEY_SIGN_TEST(), and PUBKEY_SIGN_TEST().