From: tb Date: Mon, 3 May 2021 14:48:10 +0000 (+0000) Subject: Exercise the point conversion bit for octet string representations X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b04110faed4055c2f873978cde574b1bce42c312;p=openbsd Exercise the point conversion bit for octet string representations of points on secp256r1. --- diff --git a/regress/lib/libcrypto/ec/ec_point_conversion.c b/regress/lib/libcrypto/ec/ec_point_conversion.c index 9e580180090..2c15f38135f 100644 --- a/regress/lib/libcrypto/ec/ec_point_conversion.c +++ b/regress/lib/libcrypto/ec/ec_point_conversion.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_point_conversion.c,v 1.2 2021/05/03 14:46:18 tb Exp $ */ +/* $OpenBSD: ec_point_conversion.c,v 1.3 2021/05/03 14:48:10 tb Exp $ */ /* * Copyright (c) 2021 Theo Buehler * Copyright (c) 2021 Joel Sing @@ -549,6 +549,284 @@ static const struct point_conversion { .octets_len = 145, .valid = 0, }, + + { + .description = "point at infinity on secp256r1", + .nid = NID_X9_62_prime256v1, + .octets = { 0x00 }, + .octets_len = 1, + .valid = 1, + }, + { + .description = "point at infinity on secp256r1 (flipped y_bit)", + .nid = NID_X9_62_prime256v1, + .octets = { 0x01 }, + .octets_len = 1, + .valid = 0, + }, + { + .description = "zero x compressed point on secp256r1", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, + }, + .octets_len = 33, + .valid = 1, + }, + { + .description = + "zero x compressed point on secp256r1 (flipped y_bit)", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, + }, + .octets_len = 33, + .valid = 1, + }, + { + .description = "generic compressed point on secp256r1", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x03, 0xa3, 0x96, 0xa0, 0x42, 0x73, 0x1a, 0x8b, + 0x90, 0xd8, 0xcb, 0xae, 0xda, 0x1b, 0x23, 0x11, + 0x77, 0x5f, 0x6a, 0x4c, 0xb4, 0x57, 0xbf, 0xe0, + 0x65, 0xd4, 0x09, 0x11, 0x5f, 0x54, 0xe4, 0xee, + 0xdd, + }, + .octets_len = 33, + .valid = 1, + }, + { + .description = + "generic compressed point on secp256r1 (flipped y_bit)", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x02, 0xa3, 0x96, 0xa0, 0x42, 0x73, 0x1a, 0x8b, + 0x90, 0xd8, 0xcb, 0xae, 0xda, 0x1b, 0x23, 0x11, + 0x77, 0x5f, 0x6a, 0x4c, 0xb4, 0x57, 0xbf, 0xe0, + 0x65, 0xd4, 0x09, 0x11, 0x5f, 0x54, 0xe4, 0xee, + 0xdd, + }, + .octets_len = 33, + .valid = 1, + }, + { + .description = "zero x uncompressed point #1 on secp256r1", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x66, 0x48, 0x5c, 0x78, 0x0e, 0x2f, 0x83, + 0xd7, 0x24, 0x33, 0xbd, 0x5d, 0x84, 0xa0, 0x6b, + 0xb6, 0x54, 0x1c, 0x2a, 0xf3, 0x1d, 0xae, 0x87, + 0x17, 0x28, 0xbf, 0x85, 0x6a, 0x17, 0x4f, 0x93, + 0xf4, + }, + .octets_len = 65, + .valid = 1, + }, + { + .description = + "zero x uncompressed point #1 on secp256r1 (flipped y_bit)", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x66, 0x48, 0x5c, 0x78, 0x0e, 0x2f, 0x83, + 0xd7, 0x24, 0x33, 0xbd, 0x5d, 0x84, 0xa0, 0x6b, + 0xb6, 0x54, 0x1c, 0x2a, 0xf3, 0x1d, 0xae, 0x87, + 0x17, 0x28, 0xbf, 0x85, 0x6a, 0x17, 0x4f, 0x93, + 0xf4, + }, + .octets_len = 65, + .valid = 0, + }, + { + .description = "zero x uncompressed point #2 on secp256r1", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x99, 0xb7, 0xa3, 0x86, 0xf1, 0xd0, 0x7c, + 0x29, 0xdb, 0xcc, 0x42, 0xa2, 0x7b, 0x5f, 0x94, + 0x49, 0xab, 0xe3, 0xd5, 0x0d, 0xe2, 0x51, 0x78, + 0xe8, 0xd7, 0x40, 0x7a, 0x95, 0xe8, 0xb0, 0x6c, + 0x0b, + }, + .octets_len = 65, + .valid = 1, + }, + { + .description = + "zero x uncompressed point #2 on secp256r1 (flipped y_bit)", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x99, 0xb7, 0xa3, 0x86, 0xf1, 0xd0, 0x7c, + 0x29, 0xdb, 0xcc, 0x42, 0xa2, 0x7b, 0x5f, 0x94, + 0x49, 0xab, 0xe3, 0xd5, 0x0d, 0xe2, 0x51, 0x78, + 0xe8, 0xd7, 0x40, 0x7a, 0x95, 0xe8, 0xb0, 0x6c, + 0x0b, + }, + .octets_len = 65, + .valid = 0, + }, + { + .description = "generic uncompressed point on secp256r1", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x04, 0x23, 0xe5, 0x85, 0xa5, 0x4b, 0xda, 0x34, + 0x7e, 0xe5, 0x65, 0x53, 0x7f, 0x3b, 0xce, 0xe4, + 0x54, 0xd8, 0xa4, 0x5a, 0x53, 0x4b, 0xb0, 0x4c, + 0xb9, 0x31, 0x09, 0x29, 0xa2, 0x03, 0x4c, 0x73, + 0x20, 0xd2, 0xc6, 0x17, 0xca, 0xe3, 0xcf, 0xc2, + 0xd8, 0x31, 0xfe, 0xf1, 0x7c, 0x6f, 0x9d, 0x7a, + 0x01, 0x7c, 0x34, 0x65, 0x42, 0x05, 0xaf, 0xcc, + 0x04, 0xa3, 0x2f, 0x44, 0x14, 0xbe, 0xd8, 0xc2, + 0x03, + }, + .octets_len = 65, + .valid = 1, + }, + { + .description = + "generic uncompressed point on secp256r1 (flipped y_bit)", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x05, 0x23, 0xe5, 0x85, 0xa5, 0x4b, 0xda, 0x34, + 0x7e, 0xe5, 0x65, 0x53, 0x7f, 0x3b, 0xce, 0xe4, + 0x54, 0xd8, 0xa4, 0x5a, 0x53, 0x4b, 0xb0, 0x4c, + 0xb9, 0x31, 0x09, 0x29, 0xa2, 0x03, 0x4c, 0x73, + 0x20, 0xd2, 0xc6, 0x17, 0xca, 0xe3, 0xcf, 0xc2, + 0xd8, 0x31, 0xfe, 0xf1, 0x7c, 0x6f, 0x9d, 0x7a, + 0x01, 0x7c, 0x34, 0x65, 0x42, 0x05, 0xaf, 0xcc, + 0x04, 0xa3, 0x2f, 0x44, 0x14, 0xbe, 0xd8, 0xc2, + 0x03, + }, + .octets_len = 65, + .valid = 0, + }, + { + .description = "zero x hybrid point #1 on secp256r1", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x66, 0x48, 0x5c, 0x78, 0x0e, 0x2f, 0x83, + 0xd7, 0x24, 0x33, 0xbd, 0x5d, 0x84, 0xa0, 0x6b, + 0xb6, 0x54, 0x1c, 0x2a, 0xf3, 0x1d, 0xae, 0x87, + 0x17, 0x28, 0xbf, 0x85, 0x6a, 0x17, 0x4f, 0x93, + 0xf4, + }, + .octets_len = 65, + .valid = 1, + }, + { + .description = + "zero x hybrid point #1 on secp256r1 (flipped y_bit)", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x66, 0x48, 0x5c, 0x78, 0x0e, 0x2f, 0x83, + 0xd7, 0x24, 0x33, 0xbd, 0x5d, 0x84, 0xa0, 0x6b, + 0xb6, 0x54, 0x1c, 0x2a, 0xf3, 0x1d, 0xae, 0x87, + 0x17, 0x28, 0xbf, 0x85, 0x6a, 0x17, 0x4f, 0x93, + 0xf4, + }, + .octets_len = 65, + .valid = 0, + }, + { + .description = "zero x hybrid point #2 on secp256r1", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x99, 0xb7, 0xa3, 0x86, 0xf1, 0xd0, 0x7c, + 0x29, 0xdb, 0xcc, 0x42, 0xa2, 0x7b, 0x5f, 0x94, + 0x49, 0xab, 0xe3, 0xd5, 0x0d, 0xe2, 0x51, 0x78, + 0xe8, 0xd7, 0x40, 0x7a, 0x95, 0xe8, 0xb0, 0x6c, + 0x0b, + }, + .octets_len = 65, + .valid = 1, + }, + { + .description = + "zero x hybrid point #2 on secp256r1 (flipped y_bit)", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x99, 0xb7, 0xa3, 0x86, 0xf1, 0xd0, 0x7c, + 0x29, 0xdb, 0xcc, 0x42, 0xa2, 0x7b, 0x5f, 0x94, + 0x49, 0xab, 0xe3, 0xd5, 0x0d, 0xe2, 0x51, 0x78, + 0xe8, 0xd7, 0x40, 0x7a, 0x95, 0xe8, 0xb0, 0x6c, + 0x0b, + }, + .octets_len = 65, + .valid = 0, + }, + { + .description = "generic hybrid point on secp256r1", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x07, 0x38, 0xb2, 0x98, 0x38, 0x21, 0x6b, 0xec, + 0x87, 0xcf, 0x50, 0xbb, 0x65, 0x11, 0x96, 0x63, + 0xf3, 0x90, 0x64, 0xc3, 0x5c, 0x59, 0xa5, 0x6f, + 0xaf, 0x56, 0x2a, 0x0c, 0xc0, 0x3a, 0x9b, 0x92, + 0x85, 0x95, 0x54, 0xf3, 0x08, 0x0f, 0x78, 0x59, + 0xa2, 0x44, 0x2f, 0x19, 0x5d, 0xd5, 0xcd, 0xf6, + 0xa5, 0xbe, 0x2f, 0x83, 0x70, 0x94, 0xf5, 0xcd, + 0x8c, 0x40, 0x7f, 0xd8, 0x97, 0x92, 0x14, 0xf7, + 0xc5, + }, + .octets_len = 65, + .valid = 1, + }, + { + .description = "generic hybrid point on secp256r1", + .nid = NID_X9_62_prime256v1, + .octets = { + 0x06, 0x38, 0xb2, 0x98, 0x38, 0x21, 0x6b, 0xec, + 0x87, 0xcf, 0x50, 0xbb, 0x65, 0x11, 0x96, 0x63, + 0xf3, 0x90, 0x64, 0xc3, 0x5c, 0x59, 0xa5, 0x6f, + 0xaf, 0x56, 0x2a, 0x0c, 0xc0, 0x3a, 0x9b, 0x92, + 0x85, 0x95, 0x54, 0xf3, 0x08, 0x0f, 0x78, 0x59, + 0xa2, 0x44, 0x2f, 0x19, 0x5d, 0xd5, 0xcd, 0xf6, + 0xa5, 0xbe, 0x2f, 0x83, 0x70, 0x94, 0xf5, 0xcd, + 0x8c, 0x40, 0x7f, 0xd8, 0x97, 0x92, 0x14, 0xf7, + 0xc5, + }, + .octets_len = 65, + .valid = 0, + }, }; static const size_t N_POINT_CONVERSIONS =