Classes | Functions | Variables
ec_test.cc File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <gtest/gtest.h>
#include <openssl/bn.h>
#include <openssl/bytestring.h>
#include <openssl/crypto.h>
#include <openssl/ec_key.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/nid.h>
#include <openssl/obj.h>
#include <openssl/span.h>
#include "../../ec_extra/internal.h"
#include "../../test/file_test.h"
#include "../../test/test_util.h"
#include "../bn/internal.h"
#include "internal.h"
Include dependency graph for ec_test.cc:

Go to the source code of this file.

Classes

class  ECCurveTest
 

Functions

static std::vector< EC_builtin_curveAllCurves ()
 
static std::string CurveToString (const testing::TestParamInfo< EC_builtin_curve > &params)
 
static bssl::UniquePtr< EC_KEYDecodeECPrivateKey (const uint8_t *in, size_t in_len)
 
static bool EncodeECPoint (std::vector< uint8_t > *out, const EC_GROUP *group, const EC_POINT *p, point_conversion_form_t form)
 
static bool EncodeECPrivateKey (std::vector< uint8_t > *out, const EC_KEY *key)
 
static bssl::UniquePtr< BIGNUMGetBIGNUM (FileTest *t, const char *key)
 
static bssl::UniquePtr< EC_GROUPGetCurve (FileTest *t, const char *key)
 
static bssl::UniquePtr< BIGNUMHexToBIGNUM (const char *hex)
 
static std::vector< uint8_tHexToBytes (const char *str)
 
 INSTANTIATE_TEST_SUITE_P (All, ECCurveTest, testing::ValuesIn(AllCurves()), CurveToString)
 
 TEST (ECTest, ArbitraryCurve)
 
 TEST (ECTest, BrainpoolP256r1)
 
 TEST (ECTest, DeriveFromSecret)
 
 TEST (ECTest, DISABLED_ScalarBaseMultVectorsTwoPoint)
 
 TEST (ECTest, EmptyKey)
 
 TEST (ECTest, Encoding)
 
 TEST (ECTest, GroupMismatch)
 
 TEST (ECTest, HashToCurve)
 
 TEST (ECTest, HashToScalar)
 
 TEST (ECTest, ScalarBaseMultVectors)
 
 TEST (ECTest, SetKeyWithoutGroup)
 
 TEST (ECTest, SetNULLKey)
 
 TEST (ECTest, SpecifiedCurve)
 
 TEST (ECTest, ZeroPadding)
 
 TEST_P (ECCurveTest, AddingEqualPoints)
 
 TEST_P (ECCurveTest, Compare)
 
 TEST_P (ECCurveTest, DoubleSpecialCase)
 
 TEST_P (ECCurveTest, GenerateFIPS)
 
 TEST_P (ECCurveTest, GPlusMinusG)
 
 TEST_P (ECCurveTest, IgnoreOct2PointReturnValue)
 
 TEST_P (ECCurveTest, IsOnCurve)
 
 TEST_P (ECCurveTest, Mul)
 
 TEST_P (ECCurveTest, MulNonMinimal)
 
 TEST_P (ECCurveTest, MulOrder)
 
 TEST_P (ECCurveTest, MulOutOfRange)
 
 TEST_P (ECCurveTest, MulZero)
 
 TEST_P (ECCurveTest, P224Bug)
 
 TEST_P (ECCurveTest, SetAffine)
 
 TEST_P (ECCurveTest, SetInvalidPrivateKey)
 

Variables

static const uint8_t kECKeyMissingZeros []
 
static const uint8_t kECKeySpecifiedCurve []
 
static const uint8_t kECKeyWithoutPublic []
 
static const uint8_t kECKeyWithZeros []
 

Function Documentation

◆ AllCurves()

static std::vector<EC_builtin_curve> AllCurves ( )
static

Definition at line 894 of file ec_test.cc.

◆ CurveToString()

static std::string CurveToString ( const testing::TestParamInfo< EC_builtin_curve > &  params)
static

Definition at line 901 of file ec_test.cc.

◆ DecodeECPrivateKey()

static bssl::UniquePtr<EC_KEY> DecodeECPrivateKey ( const uint8_t in,
size_t  in_len 
)
static

Definition at line 110 of file ec_test.cc.

◆ EncodeECPoint()

static bool EncodeECPoint ( std::vector< uint8_t > *  out,
const EC_GROUP group,
const EC_POINT p,
point_conversion_form_t  form 
)
static

Definition at line 137 of file ec_test.cc.

◆ EncodeECPrivateKey()

static bool EncodeECPrivateKey ( std::vector< uint8_t > *  out,
const EC_KEY key 
)
static

Definition at line 123 of file ec_test.cc.

◆ GetBIGNUM()

static bssl::UniquePtr<BIGNUM> GetBIGNUM ( FileTest t,
const char *  key 
)
static

Definition at line 934 of file ec_test.cc.

◆ GetCurve()

static bssl::UniquePtr<EC_GROUP> GetCurve ( FileTest t,
const char *  key 
)
static

Definition at line 910 of file ec_test.cc.

◆ HexToBIGNUM()

static bssl::UniquePtr<BIGNUM> HexToBIGNUM ( const char *  hex)
static

Definition at line 422 of file ec_test.cc.

◆ HexToBytes()

static std::vector<uint8_t> HexToBytes ( const char *  str)
static

Definition at line 1053 of file ec_test.cc.

◆ INSTANTIATE_TEST_SUITE_P()

INSTANTIATE_TEST_SUITE_P ( All  ,
ECCurveTest  ,
testing::ValuesIn(AllCurves())  ,
CurveToString   
)

◆ TEST() [1/14]

TEST ( ECTest  ,
ArbitraryCurve   
)

Definition at line 217 of file ec_test.cc.

◆ TEST() [2/14]

TEST ( ECTest  ,
BrainpoolP256r1   
)

Definition at line 430 of file ec_test.cc.

◆ TEST() [3/14]

TEST ( ECTest  ,
DeriveFromSecret   
)

Definition at line 1061 of file ec_test.cc.

◆ TEST() [4/14]

TEST ( ECTest  ,
DISABLED_ScalarBaseMultVectorsTwoPoint   
)

Definition at line 991 of file ec_test.cc.

◆ TEST() [5/14]

TEST ( ECTest  ,
EmptyKey   
)

Definition at line 414 of file ec_test.cc.

◆ TEST() [6/14]

TEST ( ECTest  ,
Encoding   
)

Definition at line 153 of file ec_test.cc.

◆ TEST() [7/14]

TEST ( ECTest  ,
GroupMismatch   
)

Definition at line 399 of file ec_test.cc.

◆ TEST() [8/14]

TEST ( ECTest  ,
HashToCurve   
)

Definition at line 1126 of file ec_test.cc.

◆ TEST() [9/14]

TEST ( ECTest  ,
HashToScalar   
)

Definition at line 1208 of file ec_test.cc.

◆ TEST() [10/14]

TEST ( ECTest  ,
ScalarBaseMultVectors   
)

Definition at line 944 of file ec_test.cc.

◆ TEST() [11/14]

TEST ( ECTest  ,
SetKeyWithoutGroup   
)

Definition at line 370 of file ec_test.cc.

◆ TEST() [12/14]

TEST ( ECTest  ,
SetNULLKey   
)

Definition at line 385 of file ec_test.cc.

◆ TEST() [13/14]

TEST ( ECTest  ,
SpecifiedCurve   
)

Definition at line 201 of file ec_test.cc.

◆ TEST() [14/14]

TEST ( ECTest  ,
ZeroPadding   
)

Definition at line 185 of file ec_test.cc.

◆ TEST_P() [1/15]

TEST_P ( ECCurveTest  ,
AddingEqualPoints   
)

Definition at line 618 of file ec_test.cc.

◆ TEST_P() [2/15]

TEST_P ( ECCurveTest  ,
Compare   
)

Definition at line 557 of file ec_test.cc.

◆ TEST_P() [3/15]

TEST_P ( ECCurveTest  ,
DoubleSpecialCase   
)

Definition at line 832 of file ec_test.cc.

◆ TEST_P() [4/15]

TEST_P ( ECCurveTest  ,
GenerateFIPS   
)

Definition at line 611 of file ec_test.cc.

◆ TEST_P() [5/15]

TEST_P ( ECCurveTest  ,
GPlusMinusG   
)

Definition at line 883 of file ec_test.cc.

◆ TEST_P() [6/15]

TEST_P ( ECCurveTest  ,
IgnoreOct2PointReturnValue   
)

Definition at line 805 of file ec_test.cc.

◆ TEST_P() [7/15]

TEST_P ( ECCurveTest  ,
IsOnCurve   
)

Definition at line 533 of file ec_test.cc.

◆ TEST_P() [8/15]

TEST_P ( ECCurveTest  ,
Mul   
)

Definition at line 743 of file ec_test.cc.

◆ TEST_P() [9/15]

TEST_P ( ECCurveTest  ,
MulNonMinimal   
)

Definition at line 765 of file ec_test.cc.

◆ TEST_P() [10/15]

TEST_P ( ECCurveTest  ,
MulOrder   
)

Definition at line 677 of file ec_test.cc.

◆ TEST_P() [11/15]

TEST_P ( ECCurveTest  ,
MulOutOfRange   
)

Definition at line 702 of file ec_test.cc.

◆ TEST_P() [12/15]

TEST_P ( ECCurveTest  ,
MulZero   
)

Definition at line 647 of file ec_test.cc.

◆ TEST_P() [13/15]

TEST_P ( ECCurveTest  ,
P224Bug   
)

Definition at line 854 of file ec_test.cc.

◆ TEST_P() [14/15]

TEST_P ( ECCurveTest  ,
SetAffine   
)

Definition at line 490 of file ec_test.cc.

◆ TEST_P() [15/15]

TEST_P ( ECCurveTest  ,
SetInvalidPrivateKey   
)

Definition at line 787 of file ec_test.cc.

Variable Documentation

◆ kECKeyMissingZeros

const uint8_t kECKeyMissingZeros[]
static
Initial value:
= {
0x30, 0x58, 0x02, 0x01, 0x01, 0x04, 0x01, 0x01, 0xa0, 0x0a, 0x06, 0x08, 0x2a,
0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04,
0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47, 0xf8, 0xbc, 0xe6, 0xe5, 0x63,
0xa4, 0x40, 0xf2, 0x77, 0x03, 0x7d, 0x81, 0x2d, 0xeb, 0x33, 0xa0, 0xf4, 0xa1,
0x39, 0x45, 0xd8, 0x98, 0xc2, 0x96, 0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f,
0x9b, 0x8e, 0xe7, 0xeb, 0x4a, 0x7c, 0x0f, 0x9e, 0x16, 0x2b, 0xce, 0x33, 0x57,
0x6b, 0x31, 0x5e, 0xce, 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, 0xf5,
}

Definition at line 82 of file ec_test.cc.

◆ kECKeySpecifiedCurve

const uint8_t kECKeySpecifiedCurve[]
static
Initial value:
= {
0x30, 0x82, 0x01, 0x22, 0x02, 0x01, 0x01, 0x04, 0x20, 0xc6, 0xc1, 0xaa,
0xda, 0x15, 0xb0, 0x76, 0x61, 0xf8, 0x14, 0x2c, 0x6c, 0xaf, 0x0f, 0xdb,
0x24, 0x1a, 0xff, 0x2e, 0xfe, 0x46, 0xc0, 0x93, 0x8b, 0x74, 0xf2, 0xbc,
0xc5, 0x30, 0x52, 0xb0, 0x77, 0xa0, 0x81, 0xfa, 0x30, 0x81, 0xf7, 0x02,
0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01,
0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x30, 0x5b, 0x04, 0x20, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
0x04, 0x20, 0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, 0xb3, 0xeb,
0xbd, 0x55, 0x76, 0x98, 0x86, 0xbc, 0x65, 0x1d, 0x06, 0xb0, 0xcc, 0x53,
0xb0, 0xf6, 0x3b, 0xce, 0x3c, 0x3e, 0x27, 0xd2, 0x60, 0x4b, 0x03, 0x15,
0x00, 0xc4, 0x9d, 0x36, 0x08, 0x86, 0xe7, 0x04, 0x93, 0x6a, 0x66, 0x78,
0xe1, 0x13, 0x9d, 0x26, 0xb7, 0x81, 0x9f, 0x7e, 0x90, 0x04, 0x41, 0x04,
0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47, 0xf8, 0xbc, 0xe6, 0xe5,
0x63, 0xa4, 0x40, 0xf2, 0x77, 0x03, 0x7d, 0x81, 0x2d, 0xeb, 0x33, 0xa0,
0xf4, 0xa1, 0x39, 0x45, 0xd8, 0x98, 0xc2, 0x96, 0x4f, 0xe3, 0x42, 0xe2,
0xfe, 0x1a, 0x7f, 0x9b, 0x8e, 0xe7, 0xeb, 0x4a, 0x7c, 0x0f, 0x9e, 0x16,
0x2b, 0xce, 0x33, 0x57, 0x6b, 0x31, 0x5e, 0xce, 0xcb, 0xb6, 0x40, 0x68,
0x37, 0xbf, 0x51, 0xf5, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbc,
0xe6, 0xfa, 0xad, 0xa7, 0x17, 0x9e, 0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc,
0x63, 0x25, 0x51, 0x02, 0x01, 0x01,
}

Definition at line 51 of file ec_test.cc.

◆ kECKeyWithoutPublic

const uint8_t kECKeyWithoutPublic[]
static
Initial value:
= {
0x30, 0x31, 0x02, 0x01, 0x01, 0x04, 0x20, 0xc6, 0xc1, 0xaa, 0xda, 0x15, 0xb0,
0x76, 0x61, 0xf8, 0x14, 0x2c, 0x6c, 0xaf, 0x0f, 0xdb, 0x24, 0x1a, 0xff, 0x2e,
0xfe, 0x46, 0xc0, 0x93, 0x8b, 0x74, 0xf2, 0xbc, 0xc5, 0x30, 0x52, 0xb0, 0x77,
0xa0, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07,
}

Definition at line 42 of file ec_test.cc.

◆ kECKeyWithZeros

const uint8_t kECKeyWithZeros[]
static
Initial value:
= {
0x30, 0x77, 0x02, 0x01, 0x01, 0x04, 0x20, 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, 0x01,
0xa0, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0xa1,
0x44, 0x03, 0x42, 0x00, 0x04, 0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47,
0xf8, 0xbc, 0xe6, 0xe5, 0x63, 0xa4, 0x40, 0xf2, 0x77, 0x03, 0x7d, 0x81, 0x2d,
0xeb, 0x33, 0xa0, 0xf4, 0xa1, 0x39, 0x45, 0xd8, 0x98, 0xc2, 0x96, 0x4f, 0xe3,
0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b, 0x8e, 0xe7, 0xeb, 0x4a, 0x7c, 0x0f, 0x9e,
0x16, 0x2b, 0xce, 0x33, 0x57, 0x6b, 0x31, 0x5e, 0xce, 0xcb, 0xb6, 0x40, 0x68,
0x37, 0xbf, 0x51, 0xf5,
}

Definition at line 95 of file ec_test.cc.



grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:11