diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..01b2ef9 --- /dev/null +++ b/.clang-format @@ -0,0 +1,136 @@ +--- +Language: Cpp +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: true +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: TopLevel +AlwaysBreakAfterReturnType: TopLevelDefinitions +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterCaseLabel: false + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeComma +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: true +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + - Regex: '.*' + Priority: 1 + SortPriority: 0 +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: true +IndentGotoLabels: true +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: false +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Right +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +Standard: Latest +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +... + diff --git a/examples/selfhosted/keys.h b/examples/selfhosted/keys.h index 3d10f63..c3dd74b 100644 --- a/examples/selfhosted/keys.h +++ b/examples/selfhosted/keys.h @@ -9,309 +9,349 @@ #ifndef __KEYS_H #define __KEYS_H -// clang-format off +static const unsigned char g_ecc_public_key_prime256v1_der[] + = { 0x04, 0x11, 0xca, 0x9a, 0xff, 0xb3, 0xae, 0x07, 0xf1, 0xdd, 0x4d, + 0xf2, 0x4f, 0x2c, 0xe7, 0x82, 0x00, 0x2e, 0x4b, 0x20, 0xe2, 0x46, + 0xd1, 0x25, 0x89, 0x0c, 0x2b, 0xc0, 0x08, 0xa0, 0xdd, 0x28, 0x71, + 0xdd, 0xea, 0xff, 0xa4, 0x48, 0xcb, 0xfb, 0x50, 0xcc, 0xc9, 0x37, + 0xcb, 0x33, 0xb8, 0xd5, 0x36, 0xec, 0x2e, 0x73, 0xb1, 0x51, 0xe8, + 0x2f, 0xc8, 0xdb, 0xb0, 0x68, 0x10, 0x88, 0x93, 0x4b, 0x77 }; +static const unsigned int g_ecc_public_key_prime256v1_der_len = 65; -uint8_t g_ecc_public_key_p256r1[] = -{ -0x04, -0x75,0x64,0xfd,0x3f,0x96,0xe8,0x79,0x84,0x9b,0xf9,0x7c,0xc8,0xbb,0x28,0x5d,0xa1, -0x27,0x01,0xfb,0x4f,0xd5,0xff,0x4b,0xab,0x7e,0x52,0x17,0xbf,0x09,0x15,0xe9,0x48, -0xb0,0x54,0xbe,0x64,0x70,0xe5,0x28,0xd9,0xe1,0x45,0xfc,0xbc,0xdc,0x01,0x6f,0x6a, -0x4a,0xa1,0x55,0x8b,0x89,0xc8,0xe1,0x6f,0x90,0x1e,0xe1,0xc3,0xd4,0x60,0xa8,0xcc, -}; - -uint8_t g_ecc_public_key_p384[] = -{ -0x04, -0xee,0x98,0xe9,0xaa,0x26,0x71,0xe8,0x72,0xcd,0x80,0xa9,0x6b,0x26,0x1f,0xb5,0x8d, -0xcf,0x8d,0xe8,0x21,0xd9,0xf8,0x51,0x50,0x3e,0xdc,0x5a,0xa8,0xf6,0x50,0xee,0x7e, -0x11,0xc2,0x24,0x9b,0xe6,0xde,0xe1,0xf3,0x43,0x1d,0x44,0x43,0xd9,0xd7,0x24,0xbf, -0xb3,0xd9,0xea,0xd8,0xd7,0x57,0x4c,0xbc,0x8e,0x6b,0xfa,0x5d,0xb8,0xda,0x9e,0xe6, -0x10,0x91,0x99,0x5d,0x73,0xd4,0x0e,0x4b,0x12,0xa5,0x42,0x9f,0xdc,0xff,0x2b,0x52, -0x55,0xa3,0xf9,0x9f,0x00,0xec,0x9b,0x1b,0x25,0x2d,0xb3,0xaa,0xd7,0x50,0x8b,0x36, -}; +static const unsigned char g_ecc_signature_prime256v1_sig[] + = { 0x30, 0x44, 0x02, 0x20, 0x7e, 0x49, 0x2b, 0x00, 0x19, 0x72, 0xf5, 0xcd, + 0xcd, 0x58, 0xab, 0x99, 0x59, 0x16, 0x03, 0x29, 0x68, 0x01, 0xb9, 0xc4, + 0x23, 0x6c, 0xb7, 0x22, 0x5a, 0x46, 0x4d, 0x0c, 0x6d, 0x3b, 0xdc, 0x66, + 0x02, 0x20, 0x30, 0x5e, 0xfe, 0x30, 0xfd, 0x22, 0xc0, 0x83, 0xbc, 0x72, + 0x18, 0x06, 0x2d, 0x4e, 0xfb, 0x4a, 0x47, 0x9d, 0x07, 0xc4, 0x8c, 0x1c, + 0xe7, 0xd6, 0xc0, 0x7c, 0xb0, 0xf3, 0x08, 0xc7, 0x7c, 0x5b }; +static const unsigned int g_ecc_signature_prime256v1_sig_len = 70; -uint8_t g_ecc_public_key_c25519[] = -{ -// LITTLE-ENDIAN -0xf8,0x5d,0x06,0x5d,0xd7,0xa4,0xe2,0xb8,0x72,0x27,0xf2,0x38,0x2b,0x44,0x4b,0xf5, -0xd2,0x29,0x60,0x70,0x3c,0xdc,0x86,0xc0,0xef,0xd2,0xd3,0x4d,0x5d,0xe1,0xdb,0x26, -}; - -uint8_t g_ecc_public_key_ed25519[] = -{ -// LITTLE-ENDIAN -0x77,0xee,0xaf,0x7f,0x13,0x65,0xcc,0x5f,0x60,0xcf,0x3d,0x7e,0x08,0xa6,0x2f,0xf0, -0xf8,0x18,0x1a,0xc8,0x1c,0x21,0x29,0xe8,0xf9,0x12,0x7f,0x44,0x26,0xfe,0x58,0x32, -}; +static const unsigned char g_ecc_public_key_secp384r1_der[] + = { 0x04, 0x70, 0x6a, 0x87, 0x82, 0x9c, 0x8c, 0x92, 0x31, 0x8d, 0xf7, + 0xec, 0x73, 0xbd, 0x80, 0xf3, 0xfa, 0xca, 0x65, 0x00, 0x41, 0x66, + 0x8a, 0x6f, 0x14, 0x94, 0x1a, 0x48, 0xb1, 0x5a, 0x12, 0x51, 0x44, + 0x42, 0xe4, 0xf5, 0x22, 0x9d, 0x08, 0x8f, 0x43, 0xe5, 0x0e, 0xa4, + 0xfc, 0x5d, 0x49, 0xf3, 0x15, 0x8c, 0x0d, 0x7e, 0x12, 0x13, 0x62, + 0x61, 0xea, 0x8b, 0x32, 0xc1, 0x72, 0x32, 0xf1, 0x76, 0x8a, 0x77, + 0x7d, 0x2d, 0xef, 0xa6, 0x62, 0xbe, 0x11, 0xf2, 0xb5, 0x94, 0x33, + 0x6d, 0xe2, 0x87, 0xa4, 0x2f, 0x5d, 0x5d, 0x93, 0xb8, 0x2d, 0xad, + 0xe2, 0xca, 0x43, 0x5f, 0x87, 0x1f, 0x3c, 0x85, 0xd2 }; +static const unsigned int g_ecc_public_key_secp384r1_der_len = 97; -uint8_t g_rsa_public_key_2048[] = -{ -// ASN.1/DER -0x30,0x82,0x01,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01, -0x01,0x05,0x00,0x03,0x82,0x01,0x0f,0x00,0x30,0x82,0x01,0x0a,0x02,0x82,0x01,0x01, -0x00,0xc0,0xa3,0x67,0x5d,0xd5,0x76,0xa3,0x9f,0xc7,0x53,0x3a,0x6b,0x83,0x76,0x5f, -0xf7,0x1d,0x0d,0xe3,0x55,0x19,0xaa,0x95,0x71,0x09,0x22,0x88,0x11,0x5d,0x17,0x73, -0x7b,0xcf,0x09,0xb1,0xe0,0xff,0xee,0xe4,0x6b,0x1e,0x72,0x23,0xeb,0x36,0x68,0x05, -0xbb,0xdf,0x0e,0x17,0x29,0xc0,0x9e,0x07,0x8c,0xb9,0xf7,0x79,0x32,0x79,0x73,0x67, -0x19,0x35,0x17,0xe4,0xd9,0x3d,0x8e,0x95,0x95,0xcb,0xc4,0xa6,0x0b,0x78,0x48,0x1b, -0xf7,0x11,0x48,0xbc,0xfd,0x57,0xd7,0x57,0xbd,0x19,0x2d,0x0e,0x31,0x50,0xef,0x00, -0xfa,0x20,0xe6,0xf1,0xfb,0xef,0x10,0xae,0x37,0x83,0x4a,0x19,0x4c,0x58,0xc3,0xce, -0x7e,0xc5,0xeb,0xe0,0xbd,0x5a,0x36,0x49,0xa5,0xda,0x46,0x68,0x3e,0x3e,0x6b,0x40, -0x5b,0x60,0xd8,0x84,0x19,0xf1,0xc9,0xb2,0xe8,0x4e,0x10,0x07,0x5e,0xed,0xb9,0xad, -0x6d,0x30,0xd7,0x16,0x51,0xa9,0xdf,0xe9,0x40,0xc9,0x89,0xfc,0x78,0x81,0xbe,0x94, -0x51,0x6a,0x04,0x9d,0xff,0x5d,0xc1,0xab,0x4a,0xa2,0x3f,0x7d,0xb9,0x1f,0x98,0xbc, -0xa1,0xc0,0xf2,0xee,0xe1,0x90,0x28,0xff,0xab,0x86,0xec,0x05,0x3c,0xe6,0x6b,0x31, -0x02,0x59,0xf6,0xab,0x65,0x42,0x25,0x5b,0xfb,0xea,0x11,0x2a,0xc4,0x10,0xc7,0xca, -0x85,0xe2,0x74,0x19,0x2a,0xd5,0x9d,0x9d,0x5d,0xee,0x84,0xce,0x8b,0xe8,0x28,0x68, -0xcb,0x16,0xe2,0xde,0xfb,0x04,0x81,0x58,0x0d,0x01,0xfa,0x09,0xc2,0x09,0x69,0x1d, -0xf3,0x67,0x40,0x17,0xe3,0xb3,0xb1,0x1c,0xdc,0xfe,0xb7,0xa5,0xde,0x3a,0xa4,0x01, -0xc9,0x02,0x03,0x01,0x00,0x01, -}; +static const unsigned char g_ecc_signature_secp384r1_sig[] + = { 0x30, 0x66, 0x02, 0x31, 0x00, 0x99, 0x08, 0xb4, 0xf3, 0xc2, 0x8b, 0x9c, + 0x75, 0xb8, 0x5e, 0xdb, 0x5e, 0x58, 0x04, 0xf4, 0x84, 0x6f, 0xce, 0xdb, + 0x52, 0x57, 0x25, 0xf1, 0xc2, 0xb3, 0xd4, 0x77, 0xb9, 0xcc, 0xe5, 0xff, + 0x4a, 0xcd, 0x23, 0x50, 0x85, 0x9b, 0x8f, 0x1b, 0x0f, 0xcb, 0x40, 0xea, + 0x48, 0xa9, 0x52, 0xbc, 0x07, 0x02, 0x31, 0x00, 0xdb, 0xdd, 0x8c, 0x4d, + 0xa6, 0x53, 0x6d, 0x3f, 0xb1, 0x1d, 0x14, 0x7d, 0x65, 0x02, 0xca, 0x80, + 0x77, 0x59, 0x53, 0x6d, 0xc0, 0x42, 0xac, 0xa3, 0xa1, 0x7a, 0x96, 0xf0, + 0xc6, 0x86, 0x3f, 0x3f, 0xa2, 0x7c, 0x82, 0xb1, 0x32, 0xe7, 0x8d, 0xf4, + 0x0f, 0xe0, 0xe6, 0x16, 0x99, 0x53, 0x23, 0x4c }; +static const unsigned int g_ecc_signature_secp384r1_sig_len = 104; -uint8_t g_rsa_public_key_3072[] = -{ -// ASN.1/DER -0x30,0x82,0x01,0xa2,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01, -0x01,0x05,0x00,0x03,0x82,0x01,0x8f,0x00,0x30,0x82,0x01,0x8a,0x02,0x82,0x01,0x81, -0x00,0x9a,0xf8,0x55,0xb6,0x91,0x97,0x09,0x5f,0x3d,0x76,0x8f,0x8d,0x1f,0x9d,0x18, -0x34,0x61,0x04,0x8b,0x2c,0x7f,0x77,0xf0,0x98,0xc4,0xf1,0x8d,0xc3,0xd1,0x8a,0x92, -0x26,0x01,0xb8,0xba,0x54,0xfb,0xc8,0x53,0x4f,0x99,0xed,0x30,0x0f,0xd5,0x5d,0xc8, -0x4c,0x50,0x66,0x18,0xa2,0xad,0xc8,0x22,0xb4,0x49,0x68,0xc1,0x3a,0x4b,0xaf,0x7a, -0xd0,0xae,0x21,0x70,0xba,0xd0,0xed,0xa5,0x58,0x56,0xeb,0x9c,0x69,0x13,0x1f,0xd5, -0x10,0xf2,0x35,0xff,0xf9,0xac,0x79,0xb4,0x10,0x6d,0xef,0xed,0x21,0xe6,0xf0,0x25, -0x0d,0xec,0xe7,0xc7,0x61,0x34,0xb0,0xec,0xe9,0x67,0x43,0x3a,0x8f,0x70,0xa3,0x05, -0x0c,0xb5,0x3a,0x3a,0xb7,0x12,0x31,0xbb,0x85,0xad,0x77,0x47,0xc1,0xb8,0xcd,0x06, -0xf6,0x9b,0xee,0x1f,0x61,0x8a,0xb5,0x7c,0x7a,0x1a,0x62,0x52,0xfe,0x84,0x1d,0x9a, -0x1f,0x8a,0x72,0x10,0x03,0xd1,0xca,0x85,0xff,0x35,0x56,0x07,0x3c,0xc9,0x9e,0x9e, -0x3f,0x8d,0xee,0x13,0xce,0xf1,0xac,0x1a,0xdf,0x30,0xce,0xc2,0x10,0xab,0x0c,0x61, -0x17,0x74,0xf3,0xf6,0x11,0x4f,0xd0,0x1b,0x90,0x7f,0x55,0x52,0x94,0x30,0xf4,0xb8, -0x12,0xd3,0x41,0xe5,0x9c,0x8a,0x8d,0x06,0x55,0xe9,0x96,0xf6,0x6c,0x27,0x56,0x32, -0x40,0xbd,0x84,0xe7,0xe3,0xbd,0x92,0x30,0x18,0x00,0xf2,0xf9,0xd1,0xdc,0xcf,0xe8, -0x6b,0x85,0x9e,0x07,0x7b,0x60,0xda,0x40,0xf6,0x3b,0x93,0x5e,0x09,0xec,0xd8,0x21, -0x40,0x88,0xd1,0x82,0x34,0x3a,0xef,0x21,0x49,0x52,0x37,0x89,0xc6,0x81,0x84,0x37, -0x84,0x2f,0x56,0x6a,0x37,0xb6,0x66,0x31,0xf2,0xce,0xcd,0x8d,0x30,0xfb,0xe3,0x0b, -0x88,0xa8,0xcc,0x11,0xea,0x0b,0x20,0xfc,0x97,0x91,0x1f,0x97,0xce,0xb4,0xf1,0x32, -0xff,0x3e,0xcd,0xed,0xd7,0xf7,0x70,0x0b,0x23,0x4a,0x50,0x63,0x0e,0x10,0x12,0x2f, -0xae,0x0e,0x9f,0x51,0x25,0x90,0x89,0x22,0x8e,0x2a,0x08,0x86,0x96,0xfe,0x89,0x25, -0x7f,0xa2,0x1e,0xd8,0xeb,0xcd,0xf5,0x07,0x2c,0x50,0x2d,0xb5,0x51,0xbf,0x9e,0x6c, -0x57,0xea,0x0f,0x01,0x3c,0x8c,0x9e,0x32,0x48,0xc3,0x4b,0xd9,0x1a,0xa8,0xe9,0x25, -0xf9,0xc7,0xda,0xd7,0x16,0x12,0x06,0x33,0x1d,0xfc,0xfa,0x34,0x74,0x48,0x2f,0x0e, -0x70,0x3a,0x94,0xff,0x3c,0xe2,0x7a,0x20,0x3d,0xc5,0x79,0x81,0x0a,0x7f,0xb0,0x4d, -0xfd,0x02,0x03,0x01,0x00,0x01, -}; +static const unsigned char g_ecc_public_key_ed25519_der[] + = { 0xf4, 0x53, 0x8c, 0xa7, 0xfa, 0x01, 0x69, 0xd0, 0x50, 0xb4, 0x57, + 0x3d, 0x72, 0x7a, 0x32, 0x14, 0xe7, 0x6b, 0x9e, 0xc1, 0x31, 0x96, + 0x97, 0xdd, 0xc0, 0x04, 0xae, 0xa6, 0xbe, 0xb2, 0xdd, 0x75 }; +static const unsigned int g_ecc_public_key_ed25519_der_len = 32; -uint8_t g_rsa_public_key_4096[] = -{ -// ASN.1/DER -0x30,0x82,0x02,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01, -0x01,0x05,0x00,0x03,0x82,0x02,0x0f,0x00,0x30,0x82,0x02,0x0a,0x02,0x82,0x02,0x01, -0x00,0xc3,0x3d,0x92,0x63,0x9d,0x26,0x28,0x16,0x42,0x15,0xec,0xcd,0xd9,0x48,0xd5, -0x33,0x78,0xf2,0x33,0x05,0x8d,0x3b,0x10,0x1b,0x9e,0x4c,0x9d,0xda,0x00,0x97,0xa8, -0x9c,0xcb,0x95,0xf5,0x70,0x68,0x66,0xed,0xa0,0x07,0xcf,0x00,0xde,0x37,0x0d,0xef, -0x17,0xa6,0x33,0x96,0xcb,0x6c,0x2e,0x96,0xc4,0x58,0x64,0x45,0x27,0x54,0xee,0x0d, -0xaf,0xac,0x80,0xfe,0x51,0x7a,0x5c,0x2e,0x0c,0xea,0xef,0xea,0xeb,0xc3,0xd1,0x0b, -0x60,0xe2,0x46,0xfe,0x50,0x01,0x01,0xa7,0xf8,0x11,0x12,0xf7,0xc2,0xdc,0x71,0xb7, -0x32,0xd5,0x6a,0x09,0xf7,0x3c,0x11,0x91,0xda,0xf0,0x52,0xaa,0x9b,0x78,0x50,0xf8, -0x45,0xd0,0xd6,0xf5,0xf8,0x61,0xef,0x0c,0xda,0x9e,0x46,0x34,0xc5,0x33,0x81,0x16, -0xf0,0x4f,0xda,0x9d,0x9a,0x2b,0xc1,0x38,0x84,0x31,0x41,0x66,0xe0,0x64,0x40,0x14, -0x6a,0x1f,0xba,0x0e,0x73,0xec,0xe0,0x61,0xd0,0x7a,0x81,0x10,0x9e,0x2a,0x35,0xcc, -0x92,0x14,0x58,0xda,0x83,0x65,0xc2,0x28,0x44,0xe8,0xc6,0x4f,0x0a,0x31,0xac,0x74, -0x0c,0x59,0x2d,0x4a,0x59,0x2a,0xf2,0x20,0x84,0xc3,0xd1,0x13,0x5a,0x04,0x87,0x78, -0xf4,0xee,0xef,0xf9,0xe2,0xd2,0xe0,0x6a,0x1c,0x67,0x92,0xf0,0x59,0x9a,0x55,0x95, -0x3d,0x30,0x14,0xeb,0x2e,0xdc,0x78,0x3e,0xf5,0xe3,0x1d,0x37,0xd1,0x6c,0xd8,0x41, -0xb2,0x39,0x53,0x98,0xa7,0x60,0xf8,0x18,0xb9,0x73,0x54,0xa3,0x49,0x4a,0xfa,0x00, -0x00,0xf8,0x68,0x3c,0x4f,0xd1,0xad,0xdb,0xbe,0x46,0xfe,0x7c,0x25,0xf6,0xb7,0x1d, -0xaf,0xfe,0xf6,0xb0,0xec,0x1a,0x14,0x22,0xbd,0x34,0x85,0xad,0x32,0xef,0x92,0x40, -0xb3,0x4e,0x07,0x53,0xc6,0xc4,0xa1,0xac,0xaa,0x4c,0x7c,0xa7,0xe4,0x47,0xf0,0xaf, -0xb6,0xd9,0x3f,0xd1,0x34,0xb4,0x08,0x3e,0x74,0xb9,0xa9,0xb3,0x02,0xb9,0x57,0x80, -0x20,0x8f,0x37,0x55,0x39,0xe2,0xbd,0x4b,0x85,0xe7,0x3a,0x73,0xb9,0x2d,0x5e,0xd6, -0xfb,0x50,0x8e,0x80,0xa7,0x79,0xd8,0x4a,0x09,0xc9,0x1c,0xf6,0xd6,0x82,0xea,0x55, -0x87,0xe2,0x38,0x53,0x31,0xda,0x7c,0x0f,0x49,0xc5,0xca,0xad,0xc4,0x05,0x2b,0x41, -0x76,0x1f,0x81,0xc6,0x3d,0x6e,0x67,0xc7,0x06,0x22,0x0f,0xd9,0x72,0x80,0xad,0x87, -0x20,0x7b,0x52,0xe4,0x6b,0xa9,0xb9,0x08,0xf4,0x55,0x4e,0x06,0xfc,0x02,0xc9,0xc8, -0x4c,0xf7,0x59,0x4b,0x61,0xe4,0x40,0xda,0xc3,0x29,0x27,0x62,0x2b,0xed,0x04,0xb9, -0x8d,0x75,0x03,0xe0,0x1c,0xa3,0x27,0x7e,0x58,0x3b,0x29,0x3d,0xae,0xd7,0x59,0xad, -0xba,0x54,0x62,0xba,0x95,0xaf,0xfa,0x9d,0x3e,0xe7,0x96,0xa9,0x46,0xc9,0x39,0xf3, -0xef,0x26,0xab,0x46,0xdf,0x6f,0x79,0x3e,0x93,0xff,0x8b,0x6a,0x27,0xa7,0x54,0x90, -0xe6,0x49,0xdb,0xec,0x74,0x9e,0x2e,0xae,0x5f,0x7b,0xdb,0x9c,0x20,0x38,0x9f,0x84, -0x4a,0x53,0x96,0xc1,0x1b,0xec,0xd6,0x4e,0xad,0xdd,0x84,0xae,0x90,0x78,0xa4,0xc1, -0xf2,0xa3,0x6e,0x4c,0x4a,0xd1,0x98,0xcc,0xf9,0x76,0x7f,0x8a,0x3e,0xa5,0x60,0xeb, -0x55,0x4d,0xa5,0x36,0x1d,0x24,0x8a,0x9b,0x3f,0x3e,0xfb,0xe9,0xd7,0xdb,0x29,0xfb, -0x9b,0x02,0x03,0x01,0x00,0x01, -}; +static const unsigned char g_ecc_signature_ed25519_sig[] + = { 0xf8, 0x10, 0x10, 0x7d, 0x54, 0x8e, 0x66, 0xcf, 0xf4, 0x89, 0x7f, + 0xa4, 0x31, 0x57, 0x8c, 0xff, 0xea, 0x76, 0xc5, 0xdc, 0x1d, 0x7a, + 0x57, 0x0a, 0x45, 0x97, 0xa7, 0x64, 0x7f, 0x16, 0xe9, 0x49, 0xe8, + 0x76, 0x2b, 0xc2, 0x77, 0x59, 0x79, 0x2b, 0x20, 0x67, 0xc5, 0x23, + 0x92, 0x6f, 0x55, 0x16, 0xb1, 0x8c, 0xe1, 0x2d, 0x57, 0x4c, 0x82, + 0xb9, 0x80, 0x53, 0xa4, 0xa4, 0x37, 0x8d, 0x29, 0x05 }; +static const unsigned int g_ecc_signature_ed25519_sig_len = 64; -uint8_t g_dsa_message[] = -{ -/* SHA256 of "Tempus unum hominem manet." */ -0xb7,0x03,0xb9,0xc0,0x84,0xbe,0xe8,0xa2,0x78,0xa9,0x56,0x53,0x48,0x44,0xd7,0xfa, -0x40,0x10,0xa5,0x86,0x8c,0x0c,0x82,0xa4,0x50,0x6b,0xf8,0x1c,0x36,0x21,0x8d,0xe1, +static const unsigned char g_rsa_public_key_2048_der[] = { + 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, + 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd0, 0x84, 0x16, + 0x1e, 0x7f, 0x06, 0x9f, 0xef, 0xee, 0x25, 0x0a, 0x9e, 0x9b, 0x80, 0x79, + 0xcd, 0x8b, 0x74, 0x71, 0x75, 0xe5, 0x57, 0x6a, 0xb4, 0x83, 0xb3, 0x7e, + 0x01, 0xbf, 0x1d, 0xe2, 0x63, 0xec, 0xf3, 0x96, 0x28, 0x81, 0xdd, 0xab, + 0xa4, 0xfe, 0xb8, 0x61, 0x44, 0x65, 0x83, 0x8e, 0xb2, 0x19, 0x47, 0xdc, + 0x6e, 0x4d, 0xc9, 0x96, 0x12, 0x1d, 0x13, 0xd7, 0x89, 0xec, 0x67, 0x1a, + 0x8b, 0x03, 0x2b, 0x9d, 0xa9, 0x4c, 0xec, 0x69, 0x17, 0xf3, 0x70, 0x56, + 0xfa, 0xbe, 0x22, 0x14, 0x39, 0x50, 0xaf, 0x93, 0xd2, 0x26, 0xf4, 0x78, + 0x22, 0x2f, 0x22, 0xab, 0xdf, 0x6e, 0x43, 0x7c, 0xfe, 0xd4, 0x5a, 0x79, + 0x36, 0xb1, 0xfe, 0xe4, 0xcf, 0x60, 0x06, 0xb3, 0x28, 0x2f, 0x21, 0xaf, + 0xbb, 0xeb, 0x95, 0xa7, 0xcd, 0x87, 0xa8, 0x9d, 0x68, 0x35, 0x8a, 0xd1, + 0x7f, 0x13, 0xde, 0x4c, 0x29, 0x2a, 0xa2, 0x34, 0x27, 0x14, 0xcd, 0xb4, + 0x2e, 0x81, 0xea, 0xeb, 0x32, 0x81, 0x21, 0x67, 0x21, 0x1b, 0xd2, 0x02, + 0x9c, 0x21, 0x4c, 0x9b, 0xe2, 0x30, 0x03, 0x9c, 0xf8, 0xeb, 0x99, 0x7f, + 0x40, 0x36, 0x74, 0xd7, 0x42, 0x71, 0x5a, 0x3f, 0xd3, 0xa2, 0x9a, 0x06, + 0x21, 0xbb, 0x5e, 0x7d, 0xd9, 0x0c, 0x88, 0xec, 0x80, 0x8f, 0xe4, 0x5e, + 0x31, 0x04, 0x10, 0x94, 0x0f, 0x96, 0xc8, 0xc7, 0x72, 0xf4, 0xc6, 0xcd, + 0x98, 0x8f, 0x30, 0x1f, 0x79, 0x2d, 0x9b, 0x43, 0xaf, 0x8c, 0xd6, 0x55, + 0xb7, 0xd8, 0x9a, 0xd3, 0xa4, 0x6c, 0x70, 0xd8, 0xbc, 0xc6, 0x63, 0x60, + 0xf4, 0xbe, 0xb4, 0x73, 0x56, 0x93, 0xe9, 0x74, 0x2f, 0xd5, 0x36, 0x36, + 0x91, 0x70, 0x1c, 0xd3, 0x8d, 0xc5, 0x20, 0x20, 0x51, 0xab, 0xbb, 0x46, + 0xf4, 0xc5, 0x3a, 0x59, 0x77, 0x55, 0x68, 0x83, 0x6c, 0xdb, 0x4a, 0x21, + 0x47, 0x02, 0x03, 0x01, 0x00, 0x01 }; +static const unsigned int g_rsa_public_key_2048_der_len = 294; -// Signed with g_ecc_private_key_p256r1 DetK, HMAC_SHA256, ASN.1 -uint8_t g_ecc_signature_p256r1[] = -{ -0x30,0x45,0x02,0x21,0x00,0xaa,0x14,0x5c,0xc9,0x9f,0xc3,0x7b,0x77,0xa5,0xb8,0x54, -0xd8,0xe7,0xab,0x5e,0x92,0x52,0xcf,0xf2,0x5f,0xf6,0x12,0x7b,0x55,0x68,0xd7,0x1e, -0x06,0xbe,0x00,0xe6,0x01,0x02,0x20,0x64,0x58,0x99,0x0c,0xdd,0x99,0x9f,0x06,0x21, -0xb7,0x98,0x12,0x05,0x86,0x42,0xa4,0x11,0x89,0x28,0xd5,0x91,0x6a,0xf6,0x4b,0x0e, -0x0d,0x22,0xdb,0x73,0x3a,0xef,0x6e, +static const unsigned char g_rsa_sig_2048_der[] = { + 0x07, 0x07, 0x82, 0x11, 0xc7, 0x2d, 0xc4, 0x84, 0x1d, 0x32, 0xc5, 0x78, + 0x83, 0xdc, 0x50, 0x02, 0x97, 0xf7, 0x58, 0xa5, 0xde, 0x02, 0x03, 0x5f, + 0xb8, 0xba, 0x35, 0x4d, 0xa1, 0xb5, 0xce, 0xa3, 0x82, 0x15, 0xb2, 0x2c, + 0xd6, 0x12, 0x32, 0x43, 0x27, 0xec, 0x86, 0x25, 0x7c, 0xc3, 0x0d, 0x04, + 0x8c, 0xb2, 0x0c, 0x13, 0x64, 0x5d, 0x11, 0x64, 0x36, 0x6a, 0x62, 0x0a, + 0x88, 0xe7, 0x9f, 0x98, 0x3a, 0x56, 0x3d, 0x79, 0xba, 0x4a, 0x69, 0xe0, + 0x35, 0xf4, 0xc9, 0x01, 0xff, 0xec, 0xd3, 0x5b, 0x8e, 0x83, 0x0d, 0x7b, + 0x13, 0x9e, 0x56, 0xd4, 0xbc, 0x0c, 0xee, 0x55, 0x94, 0x42, 0xae, 0xda, + 0xf6, 0x4a, 0xd4, 0xa6, 0x0c, 0xd2, 0x0b, 0x0c, 0x69, 0xb9, 0x7a, 0x2a, + 0x7d, 0x02, 0x86, 0x77, 0x3b, 0xa4, 0x4d, 0x2b, 0x74, 0x5a, 0xb8, 0x44, + 0x7d, 0x20, 0x6b, 0x07, 0x56, 0x54, 0x73, 0x13, 0xd8, 0xa1, 0xa6, 0x9a, + 0x5f, 0x1d, 0x81, 0x9f, 0x69, 0xe0, 0x49, 0x1b, 0x03, 0x4d, 0x72, 0x31, + 0xab, 0x04, 0x5b, 0x70, 0xb5, 0xdf, 0x3e, 0x80, 0x46, 0x56, 0x39, 0xf1, + 0xd3, 0x44, 0xca, 0xae, 0xa5, 0x3d, 0x10, 0x71, 0x7f, 0x58, 0xb7, 0xaa, + 0x58, 0x3c, 0xc1, 0x43, 0x0a, 0xa6, 0x28, 0xc1, 0x18, 0xee, 0x87, 0xdf, + 0xa9, 0x42, 0xa1, 0x1b, 0x60, 0xa6, 0x45, 0x23, 0x4a, 0x47, 0xc6, 0xdf, + 0x4a, 0x48, 0x7f, 0xce, 0x99, 0xb7, 0xf7, 0x44, 0x64, 0x29, 0xc7, 0xa7, + 0xe0, 0x4d, 0x36, 0x46, 0xa8, 0x62, 0xe1, 0x92, 0xee, 0x68, 0x56, 0x5a, + 0xf0, 0xb3, 0xd0, 0x47, 0x10, 0x1b, 0x32, 0x7c, 0x4f, 0x02, 0x27, 0x9c, + 0x4a, 0x8b, 0x86, 0x82, 0xb8, 0x88, 0x4a, 0xc5, 0xed, 0xff, 0x3d, 0x4b, + 0x40, 0xda, 0xe0, 0xe4, 0xd3, 0xf8, 0xf5, 0xfe, 0x05, 0xfe, 0xd1, 0x7f, + 0x7d, 0xee, 0xea, 0xef }; +static const unsigned int g_rsa_sig_2048_der_len = 256; -// Signed with g_ecc_private_key_p384r1 DetK, HMAC_SHA256 [sic], ASN.1 -uint8_t g_ecc_signature_p384[] = -{ -0x30,0x66,0x02,0x31,0x00,0xe3,0x4b,0xad,0x5d,0x67,0xda,0x72,0x57,0x84,0xec,0xb4, -0x04,0xd3,0xf2,0x49,0xd8,0xaf,0xf5,0x07,0x67,0xb3,0xc0,0x89,0xd8,0xc6,0x6c,0x70, -0x6d,0x44,0x8e,0xc1,0x70,0x30,0x62,0x18,0x17,0x9f,0x20,0xcd,0x76,0xbd,0x7b,0x7d, -0x46,0xca,0x0b,0x4a,0x9e,0x02,0x31,0x00,0xb4,0x91,0x58,0xdf,0x87,0xeb,0x9f,0x3b, -0xb1,0x85,0xf7,0x13,0x58,0x51,0xc4,0x09,0x0e,0x93,0xd3,0x06,0x3a,0x94,0x15,0x9c, -0x34,0x16,0x69,0x2b,0xeb,0x42,0x04,0xf4,0x16,0x0b,0x58,0xc8,0xe4,0xf9,0xa4,0x42, -0xe7,0x1b,0x9a,0xff,0xcc,0x7d,0x82,0xef, +static const unsigned char g_rsa_public_key_3072_der[] = { + 0x30, 0x82, 0x01, 0xa2, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x8f, 0x00, + 0x30, 0x82, 0x01, 0x8a, 0x02, 0x82, 0x01, 0x81, 0x00, 0xc9, 0x8a, 0xf8, + 0x70, 0xac, 0x35, 0x9c, 0xab, 0x99, 0xc0, 0x93, 0x24, 0x00, 0xd6, 0xbf, + 0x42, 0xf0, 0x71, 0xb3, 0x20, 0x6d, 0x41, 0x5b, 0xea, 0x0a, 0x20, 0x08, + 0xf6, 0xdf, 0xac, 0x67, 0x75, 0x61, 0xda, 0x42, 0x3a, 0x8e, 0x02, 0x07, + 0x1b, 0xaa, 0xa8, 0xc6, 0x8f, 0x76, 0x09, 0x59, 0xac, 0x46, 0x9f, 0xae, + 0xe6, 0xb0, 0x0f, 0x10, 0x32, 0x8f, 0x69, 0xe9, 0x72, 0x50, 0x18, 0x8b, + 0xdc, 0xc9, 0x07, 0x22, 0x71, 0x29, 0x17, 0x77, 0xc0, 0x8b, 0x65, 0xc5, + 0xb7, 0xb5, 0x25, 0x05, 0x77, 0x28, 0x1f, 0x23, 0xef, 0xe0, 0xc1, 0x87, + 0x33, 0x16, 0xba, 0xa4, 0xa5, 0xff, 0x47, 0x30, 0x23, 0x8f, 0x36, 0x53, + 0x59, 0x50, 0x77, 0xd6, 0xf9, 0x3d, 0x66, 0xdd, 0xfc, 0xf3, 0xf7, 0xc5, + 0x7a, 0x7c, 0x48, 0x76, 0xe3, 0x37, 0xa3, 0x7a, 0x57, 0x1e, 0xeb, 0xa4, + 0x2a, 0xf5, 0x2f, 0x40, 0xff, 0x08, 0x5a, 0xc0, 0x5b, 0x30, 0x66, 0x99, + 0x72, 0x05, 0xa5, 0x8d, 0xc9, 0x04, 0xf2, 0x89, 0x81, 0xcd, 0x16, 0x70, + 0x25, 0xf1, 0x83, 0x91, 0xad, 0xd6, 0x50, 0x6e, 0x1e, 0xd3, 0x67, 0xbb, + 0xc3, 0xe0, 0xa5, 0x39, 0x37, 0xc2, 0x26, 0x83, 0x04, 0xe6, 0xcc, 0xa1, + 0x75, 0x46, 0xe3, 0x38, 0x1f, 0xb6, 0xcf, 0x18, 0x04, 0xeb, 0x5b, 0xec, + 0x0f, 0x52, 0x0e, 0x3d, 0xa3, 0x2b, 0x9b, 0xec, 0x7b, 0xfb, 0x74, 0x82, + 0xc3, 0x09, 0xaa, 0x54, 0xef, 0xd3, 0xa6, 0xe1, 0x91, 0xf0, 0x73, 0x15, + 0x3b, 0xd6, 0x82, 0x6c, 0x1b, 0x7d, 0x01, 0x8a, 0x06, 0xcb, 0x78, 0x18, + 0x51, 0xcf, 0x61, 0xdb, 0x05, 0xba, 0x7b, 0x37, 0x5e, 0x8b, 0x6b, 0x90, + 0xa0, 0x8b, 0xc2, 0x18, 0x8f, 0x47, 0x02, 0x50, 0xca, 0x4e, 0x4e, 0xde, + 0x26, 0x55, 0x65, 0x6c, 0x9d, 0x93, 0x20, 0x21, 0xcd, 0x9f, 0x29, 0x68, + 0xd5, 0x55, 0x88, 0x45, 0xd8, 0x34, 0xcd, 0x11, 0x74, 0x52, 0x81, 0x57, + 0x61, 0x57, 0x4a, 0xef, 0xd3, 0x63, 0x4a, 0x0a, 0x82, 0xc1, 0x4e, 0x25, + 0xb3, 0x21, 0x7f, 0x86, 0x01, 0x27, 0x20, 0xa0, 0x13, 0x21, 0x5e, 0x70, + 0xbf, 0xce, 0xce, 0xa6, 0x3a, 0xc0, 0xbd, 0xfd, 0x2c, 0x1e, 0x1f, 0x43, + 0xe8, 0xb4, 0xe9, 0x96, 0xcf, 0x23, 0x97, 0xe6, 0x94, 0xe1, 0x66, 0xea, + 0x17, 0x75, 0x0f, 0x2e, 0x0c, 0x87, 0xc3, 0x3d, 0x78, 0xdd, 0x57, 0x40, + 0xf5, 0x6b, 0x4d, 0xe6, 0x06, 0xe5, 0xa0, 0x7b, 0x64, 0x6d, 0xcc, 0xfd, + 0x26, 0x42, 0x66, 0x3c, 0x9a, 0x14, 0xcd, 0xac, 0xf1, 0xca, 0x31, 0x53, + 0x21, 0xe2, 0xed, 0x82, 0x11, 0xc5, 0xf6, 0xcc, 0xe3, 0x84, 0xd9, 0xce, + 0xa9, 0xf3, 0x6f, 0x05, 0xa0, 0x81, 0x56, 0x24, 0x4b, 0x15, 0x04, 0xbf, + 0xb9, 0x89, 0x7d, 0x4f, 0x2d, 0x32, 0xff, 0xa9, 0x01, 0x02, 0x03, 0x01, + 0x00, 0x01 }; +static const unsigned int g_rsa_public_key_3072_der_len = 422; -// Signed with g_ecc_private_key_ed25519, Raw { R | S } little endian -uint8_t g_ecc_signature_ed25519[] = -{ -0xdf,0x49,0x7d,0x8d,0xf9,0xfe,0x67,0x89,0x58,0x5d,0x4c,0xed,0x09,0x61,0x7d,0x38, -0x17,0xda,0xb8,0xcc,0x16,0x0a,0x79,0xbd,0x72,0x60,0x3d,0x56,0xaa,0x87,0x21,0x2e, -0x0f,0x3d,0x7c,0xb2,0xc2,0xb5,0x58,0xc3,0x9f,0xc9,0xe4,0x49,0x22,0x8d,0x78,0xf7, -0xbf,0x96,0x8a,0x3f,0xba,0xa8,0xf0,0x15,0xe8,0x5b,0xce,0xce,0xca,0x01,0x1d,0x0f, +static const unsigned char g_rsa_sig_3072_der[] = { + 0x0e, 0xc0, 0x2b, 0xa8, 0xd2, 0x28, 0x83, 0x37, 0x63, 0xce, 0x6a, 0x5f, + 0xe8, 0xb1, 0x56, 0x8a, 0xc6, 0xcd, 0x11, 0x95, 0x3a, 0x08, 0xeb, 0x7a, + 0x73, 0x79, 0xce, 0x4a, 0x47, 0x4e, 0x2c, 0x34, 0x0b, 0x93, 0x1b, 0x1a, + 0x8a, 0x8d, 0xac, 0xb9, 0xab, 0x6a, 0x8d, 0x62, 0x0c, 0xee, 0xfc, 0x95, + 0x75, 0xf1, 0x16, 0x82, 0x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 0xd6, 0x44, 0xa1, 0xe9, 0xb9, 0x58, + 0xc7, 0x3d, 0x33, 0xac, 0x08, 0xaa, 0xe8, 0x23, 0x23, 0xdf, 0x71, 0x99, + 0xa9, 0x8d, 0x42, 0x68, 0x60, 0x6d, 0x95, 0xb9, 0x97, 0xd5, 0x00, 0xc2, + 0xfa, 0x22, 0x24, 0x6e, 0x0c, 0xfe, 0x6b, 0x02, 0x7f, 0x3b, 0x37, 0xa6, + 0x1b, 0x5f, 0xa3, 0x8a, 0xb7, 0x1d, 0x69, 0x98, 0x35, 0xb3, 0xaa, 0xc4, + 0xb6, 0xd7, 0xc9, 0xfd, 0xc6, 0x18, 0xd9, 0xc7, 0xc8, 0x77, 0xeb, 0x48, + 0x62, 0xee, 0x53, 0xcc, 0x81, 0x22, 0x7d, 0x60, 0xa5, 0xcc, 0x35, 0xcd, + 0xf5, 0x1b, 0xa4, 0x12, 0x6d, 0xf0, 0x7d, 0xc7, 0x7a, 0x22, 0x13, 0x18, + 0x3f, 0x26, 0x06, 0x89, 0x3d, 0x51, 0x42, 0xa0, 0xa5, 0x49, 0xe0, 0xb4, + 0x97, 0x20, 0x0c, 0x44, 0x62, 0x60, 0xe5, 0xeb, 0xa8, 0x79, 0xca, 0x52, + 0x2d, 0x28, 0x5c, 0x3d, 0x06, 0x34, 0x72, 0x7c, 0xf5, 0xc8, 0x4c, 0x53, + 0x37, 0xef, 0x70, 0xb2, 0x58, 0xe6, 0x55, 0x14, 0x4d, 0xc2, 0x9e, 0xbb, + 0xea, 0xe2, 0xb4, 0x71, 0x8f, 0x51, 0x0d, 0xfc, 0xfb, 0xbf, 0x95, 0x5d }; +static const unsigned int g_rsa_sig_3072_der_len = 384; - -// Always 256 bytes -uint8_t g_rsa_sig_2048[] = -{ -0x94,0x57,0xc5,0x10,0x90,0x14,0xc6,0x5b,0x59,0xbb,0x8c,0x17,0xb7,0x27,0xde,0xe5, -0xbe,0x45,0x93,0x7c,0x00,0xfa,0xd1,0x7e,0xe7,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a1,0x3f,0x47,0xd8,0x90,0x37,0xa4,0xaf,0x56,0x65,0x51,0x9e, +static const unsigned char g_rsa_public_key_4096_der[] = { + 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00, + 0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, 0x02, 0x01, 0x00, 0xe7, 0x72, 0x31, + 0xf3, 0x13, 0xa3, 0xde, 0x32, 0x99, 0x7b, 0x4f, 0x62, 0x48, 0x46, 0xfb, + 0x26, 0x4b, 0x8e, 0x79, 0xb8, 0x3d, 0xf2, 0xc6, 0x29, 0xa2, 0xb9, 0xd9, + 0xaf, 0x8c, 0xa2, 0x0c, 0x0c, 0x8e, 0x39, 0x6c, 0x30, 0xc7, 0x9e, 0x19, + 0xa1, 0x1f, 0x73, 0xa2, 0x39, 0x81, 0x21, 0x9c, 0xd9, 0x49, 0xcb, 0xff, + 0xf3, 0xa6, 0xa0, 0x19, 0x7c, 0x93, 0xff, 0xd5, 0x52, 0x64, 0xb9, 0xf2, + 0xee, 0xbe, 0xe2, 0xb1, 0xa1, 0x3d, 0x28, 0x23, 0x41, 0x42, 0x12, 0x3f, + 0x94, 0xcd, 0x6f, 0x29, 0xe0, 0x37, 0x39, 0xdd, 0xc2, 0x06, 0x1e, 0x1c, + 0x2b, 0x9c, 0xfa, 0xe9, 0x90, 0x87, 0x7a, 0x20, 0xff, 0xc1, 0x80, 0x86, + 0x1c, 0x78, 0xd3, 0xbd, 0x39, 0x74, 0x45, 0x6d, 0x08, 0x29, 0xab, 0xf7, + 0x2e, 0x2f, 0x32, 0x20, 0x04, 0x2a, 0x46, 0xa6, 0xf4, 0x2c, 0x05, 0xb2, + 0xa8, 0x74, 0x4e, 0x60, 0x2f, 0xaf, 0x4a, 0x17, 0x80, 0x81, 0xda, 0x63, + 0x3a, 0x42, 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x85, 0x88, 0x58, 0xa1, 0x4c, 0x0a, 0xff, 0x8e, + 0x49, 0xd8, 0xa3, 0x86, 0x03, 0x02, 0x03, 0x01, 0x00, 0x01 }; +static const unsigned int g_rsa_public_key_4096_der_len = 550; -// Always 384 bytes -uint8_t g_rsa_sig_3072[] = -{ -0x2d,0x26,0x39,0xb1,0x3c,0x5b,0xe5,0x12,0xf4,0x07,0x87,0x69,0xc8,0xec,0xfc,0xef, -0x19,0x0d,0x87,0xed,0x6c,0x72,0x42,0xa1,0xc2,0x09,0x0d,0x17,0x4a,0xbb,0xd8,0x81, -0x16,0xe9,0x80,0x86,0x95,0x5f,0x96,0x48,0x65,0xfd,0x27,0xe0,0x7e,0x5c,0xfa,0x3e, -0x42,0x96,0x2c,0x43,0x81,0x41,0x71,0xc1,0xd1,0x58,0xb8,0xb6,0x87,0x04,0xfc,0x37, -0x45,0x50,0xa6,0x3d,0xff,0x9c,0xb1,0xff,0x83,0xd5,0x33,0xd3,0x0c,0xce,0xc8,0x3f, -0xcc,0x51,0x00,0x50,0xdf,0xfa,0xe1,0x0a,0x10,0x7f,0xaf,0xae,0x63,0x9f,0xcc,0x47, -0xea,0x8e,0x19,0x38,0x6e,0xbc,0xde,0xec,0x01,0x6c,0x13,0xb9,0xdf,0x06,0xb8,0x69, -0x5a,0xea,0xad,0x52,0x0a,0xcc,0xb3,0xf1,0xe2,0xbb,0x91,0x74,0xf2,0x80,0x00,0xf1, -0xc9,0xe5,0x95,0xd1,0x6a,0x0a,0xbc,0x31,0x5e,0x6d,0x31,0x2c,0x08,0x3e,0xf2,0x63, -0x2c,0x19,0x23,0x09,0x25,0xab,0x49,0x01,0x3a,0x4c,0xb8,0x2b,0xde,0xa7,0x7c,0xad, -0x8a,0x64,0x36,0x56,0x29,0x0a,0x0d,0xed,0x8a,0xd7,0xe5,0xd5,0x22,0xe1,0xe9,0xcb, -0xbf,0xb0,0x6c,0x13,0x6b,0xce,0x4b,0x52,0xa6,0x77,0x84,0x4f,0x4e,0x3b,0xec,0x92, -0x68,0xd5,0x37,0x37,0x4f,0xba,0xe6,0x9d,0x4a,0xf1,0x2c,0xdc,0xa4,0x58,0x0f,0x99, -0xfa,0x1b,0x7a,0x50,0xcc,0x71,0x1c,0xac,0x43,0xfe,0x5d,0x66,0xa4,0x30,0x45,0x61, -0x7b,0x5e,0xc9,0x3f,0xa9,0x12,0xfc,0x71,0x2c,0xf6,0x1a,0x0b,0xf6,0x19,0x87,0x0a, -0x28,0x70,0x3d,0xfa,0x93,0x00,0xea,0x79,0x47,0x9e,0x4a,0x03,0xfa,0xb8,0xcf,0x34, -0xe7,0x96,0xc2,0x8a,0x20,0x21,0x4e,0xfc,0x03,0xff,0x4a,0xc7,0xa8,0xf4,0xff,0x4f, -0x56,0xda,0x6b,0xf2,0x80,0x19,0x43,0x41,0x58,0xe1,0x5f,0x25,0xe9,0x9f,0x0d,0x0f, -0xb6,0x63,0xf9,0xad,0x89,0xa5,0x95,0xab,0x89,0x60,0xe7,0xda,0x7a,0xac,0xd4,0x7c, -0x06,0x2d,0xcf,0x61,0x6c,0x99,0x8e,0xf2,0x84,0x08,0x30,0x3a,0xff,0x8c,0x1c,0x5b, -0xca,0xd5,0x75,0x25,0x2f,0x76,0x1d,0x4f,0x23,0xe2,0x0d,0x30,0x24,0xef,0x85,0x7b, -0x46,0x85,0x65,0xaa,0x4e,0xd3,0x21,0x50,0x0a,0x25,0x7f,0xb4,0x82,0x7e,0xf7,0x27, -0x37,0x8f,0xb7,0x94,0xe7,0x07,0x0b,0x81,0xa4,0x13,0xa4,0x31,0x2f,0xc1,0xf2,0x9a, -0x29,0x70,0x05,0x67,0xa5,0xeb,0x09,0xf4,0x5c,0xdd,0x45,0x85,0xe4,0xda,0x60,0xe1, +static const unsigned char g_rsa_sig_4096_der[] = { + 0x43, 0xe7, 0xff, 0xad, 0x32, 0x0f, 0xc7, 0x60, 0x96, 0xe4, 0xd4, 0xca, + 0x48, 0x84, 0xd7, 0xaf, 0xad, 0x91, 0x2e, 0x18, 0xfe, 0xfe, 0x93, 0xad, + 0xd9, 0x31, 0x03, 0xaf, 0xef, 0x05, 0x97, 0x45, 0xdf, 0xf4, 0x96, 0x51, + 0x50, 0xb3, 0x86, 0x7a, 0xb8, 0xfa, 0x59, 0x36, 0x2f, 0x97, 0x46, 0x41, + 0x65, 0x33, 0x36, 0x62, 0x58, 0xed, 0x2b, 0xaa, 0x63, 0x16, 0x09, 0x68, + 0xcc, 0x0d, 0xc3, 0xc1, 0x55, 0x4b, 0xc5, 0x1a, 0x58, 0x25, 0x6e, 0xed, + 0x20, 0xce, 0x80, 0x0b, 0xed, 0x68, 0x93, 0xe3, 0x01, 0xa4, 0xa0, 0x42, + 0xcf, 0x62, 0xe9, 0xdb, 0x1d, 0xcf, 0xe8, 0x8c, 0x6f, 0x4e, 0x2d, 0x9a, + 0xaa, 0x08, 0x75, 0x5d, 0x24, 0x2e, 0x43, 0x00, 0xb9, 0x3d, 0x0c, 0x63, + 0xc9, 0xd9, 0x46, 0xc3, 0xe1, 0x61, 0x40, 0x19, 0xfa, 0x33, 0xf9, 0x12, + 0x08, 0x02, 0x64, 0x01, 0x12, 0xd7, 0x4f, 0x45, 0x44, 0x9e, 0xd6, 0x81, + 0x3a, 0xd5, 0x4e, 0xed, 0x33, 0x8a, 0xe7, 0x18, 0xb0, 0x6d, 0x0c, 0x27, + 0x73, 0xa4, 0xfb, 0xea, 0xe5, 0xd1, 0xb2, 0xd8, 0xfa, 0x4a, 0x09, 0x20, + 0xcc, 0xef, 0xf5, 0xfe, 0xe8, 0x63, 0x08, 0xde, 0xf3, 0xe7, 0x53, 0xa8, + 0x78, 0x3d, 0x63, 0x39, 0x09, 0xfc, 0xbe, 0x99, 0x53, 0xb8, 0xb8, 0x8f, + 0x20, 0xe1, 0xc9, 0xe7, 0xac, 0x1a, 0xd6, 0x52, 0xe0, 0xb3, 0x2c, 0x68, + 0x25, 0x44, 0x1e, 0x49, 0x6d, 0x69, 0x31, 0x15, 0xb2, 0x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 0x27, 0x90, + 0x02, 0x49, 0x8f, 0x8e, 0xa7, 0x07, 0xc9, 0x93, 0x80, 0x0b, 0x6c, 0x1e, + 0x19, 0x75, 0xb3, 0xc9, 0x93, 0x4c, 0xd1, 0x4e, 0x1b, 0x7c, 0x26, 0x9d, + 0x42, 0x4d, 0x0a, 0x02, 0x8c, 0xf4, 0x00, 0x37, 0x9e, 0x3f, 0xd4, 0xda, + 0x53, 0xd7, 0x65, 0x48, 0xee, 0x05, 0xa4, 0x44, 0x4a, 0xd6, 0x27, 0xde, + 0x2c, 0xae, 0x5e, 0x09, 0x0c, 0x52, 0x09, 0xd4, 0x77, 0x59, 0xdb, 0x76, + 0xdc, 0x9c, 0x80, 0x4b, 0xfd, 0x2d, 0xb8, 0x2c, 0x92, 0xac, 0xe4, 0xa3, + 0x4b, 0xdc, 0x80, 0xb5, 0x2c, 0x08, 0x6e, 0x32, 0x7d, 0x71, 0x68, 0x8c, + 0x12, 0x9c, 0x55, 0x0b, 0x83, 0x79, 0x95, 0x48, 0x8f, 0xc3, 0xdb, 0x01, + 0xc5, 0xd4, 0x56, 0x5f, 0x10, 0x36, 0x97, 0x66, 0x1c, 0x1f, 0xf6, 0x11, + 0x9c, 0x93, 0xd7, 0x6c, 0x19, 0xe9, 0x5a, 0xb2, 0xc4, 0xdc, 0x8b, 0x90, + 0x0b, 0x03, 0x55, 0xa0, 0x33, 0x43, 0x63, 0x4f }; +static const unsigned int g_rsa_sig_4096_der_len = 512; -// Always 512 bytes -uint8_t g_rsa_sig_4096[] = -{ -0x9f,0x30,0xd3,0xe2,0xba,0x89,0x5a,0x43,0x99,0x7b,0x84,0x6f,0x7b,0x26,0x33,0x1f, -0xb2,0x52,0x74,0x79,0x45,0x49,0xe6,0x82,0x33,0xa3,0x19,0x24,0x14,0x20,0x61,0xd3, -0x6f,0x89,0x76,0xb2,0x28,0x7f,0xf0,0x03,0x5e,0x12,0x75,0x13,0x81,0x32,0x2e,0xb5, -0x6a,0x60,0x2b,0xcd,0xe1,0x5c,0xc9,0x9e,0xe0,0xee,0x44,0xb8,0xee,0x50,0x74,0x80, -0xfc,0x68,0x60,0x6a,0xcf,0xf9,0x10,0x4e,0x97,0xaf,0xf4,0x42,0xcb,0x71,0x84,0x98, -0x55,0x8b,0x61,0x65,0xfd,0x9b,0x99,0xbe,0xd3,0xf9,0xc7,0x19,0x3c,0x15,0x3a,0xa4, -0x3d,0x7a,0xeb,0x0b,0x81,0x8b,0x86,0x5a,0xb4,0x25,0x68,0xe5,0x40,0x64,0xa7,0x2e, -0xc3,0x5e,0x6c,0x72,0xba,0x7f,0xcb,0xfd,0x91,0x9c,0x69,0x20,0x46,0xef,0xc5,0xd2, -0x73,0x30,0x43,0x6d,0x89,0x91,0xbf,0x41,0x99,0x81,0xfb,0xbc,0xcb,0xe1,0x9c,0xb1, -0x62,0x5a,0x41,0x3f,0xd6,0xb9,0xe2,0xd1,0x90,0xe1,0xd2,0x77,0xf4,0xde,0xcf,0xc1, -0xf0,0x62,0xf8,0x46,0x7e,0x8e,0xfc,0x43,0xe4,0xa3,0x75,0x49,0x1c,0xd7,0x02,0x72, -0x17,0xb8,0x7b,0x71,0x50,0x1c,0xda,0xef,0x4c,0x3d,0x85,0x7b,0xd1,0x27,0x25,0x60, -0x3a,0xb2,0x0f,0x2b,0x7b,0xc2,0x65,0x9b,0xef,0x63,0x25,0xe2,0xfe,0x42,0x70,0xc7, -0x8d,0x40,0xb0,0xd9,0xba,0x94,0xd3,0x9b,0x1c,0x33,0x7d,0x54,0x3d,0xf8,0x30,0xaf, -0x98,0x11,0x6e,0x2d,0x8a,0x21,0xd6,0x1a,0xa7,0x22,0x1e,0x05,0xde,0xb3,0x66,0x04, -0x2c,0x20,0xf6,0xc6,0xb5,0xf7,0x40,0x58,0x50,0xe5,0xf8,0x9b,0xf9,0x11,0x1a,0x2e, -0x41,0x61,0x40,0xa9,0xca,0x3f,0x4e,0xe0,0xee,0x1c,0x3b,0xae,0x73,0x10,0xaa,0xdf, -0x94,0xd4,0xd8,0x49,0x30,0xc7,0x61,0x5b,0x67,0x80,0x5b,0x2b,0xa2,0x14,0x46,0x67, -0xe7,0x8c,0x11,0xc4,0xfc,0x00,0xd5,0xf3,0x99,0xfb,0x00,0x04,0x12,0x72,0x0c,0x23, -0xf5,0xc6,0xa1,0xaf,0xfa,0x27,0x7a,0xb8,0xb8,0xef,0x5c,0x05,0x95,0x9c,0x09,0xa5, -0xf5,0x90,0x56,0x70,0x4f,0xf9,0x17,0x06,0xa4,0xad,0x65,0x91,0x14,0x20,0x46,0x39, -0x2a,0xe0,0xaf,0xbe,0xab,0x14,0xf4,0x14,0x6d,0xa6,0x34,0xfc,0x5c,0xd7,0x9e,0xad, -0x59,0x8e,0x84,0xfc,0xe2,0x99,0x0c,0x7f,0x46,0xfd,0x28,0x50,0xa0,0x55,0x51,0x74, -0xc8,0x2f,0x47,0x00,0x7a,0x24,0x31,0x97,0x74,0xdd,0xb6,0x06,0x8b,0xce,0xcf,0x20, -0x35,0x2e,0x2b,0x9d,0x28,0x7c,0x8a,0xf5,0x02,0x0f,0xb3,0xb8,0x71,0x9d,0xc3,0xed, -0x97,0x2b,0xf7,0x88,0x87,0xa9,0x91,0xd4,0x26,0x38,0xdc,0x04,0xfb,0x2b,0x6e,0xae, -0xc4,0x1e,0x14,0x75,0xa3,0xa4,0xb5,0xd9,0xa6,0xe2,0xf0,0xb5,0xdb,0xab,0xa3,0x56, -0x6d,0x21,0xb4,0x71,0xd4,0x20,0xf3,0xfe,0x82,0xfb,0x09,0x5d,0x6d,0xc3,0x22,0x87, -0x7e,0xa9,0x92,0x62,0xf3,0x49,0x8c,0x88,0x17,0x7e,0xf3,0x76,0x12,0x7d,0x36,0x09, -0x97,0xdc,0x28,0x2a,0x73,0xe6,0x91,0xcb,0x0b,0xbc,0x4d,0xe3,0x7f,0x91,0xad,0x8c, -0x99,0x47,0x51,0x70,0x12,0x6f,0x58,0x55,0x5b,0xc2,0x43,0xa8,0xf8,0xc8,0xa3,0xb2, -0x63,0x59,0xa6,0x36,0xd8,0x53,0x1c,0x2a,0xa0,0x94,0xb4,0x0e,0x36,0x0d,0x5a,0x68, +uint8_t g_ecc_public_key_c25519[] = { + // LITTLE-ENDIAN + 0xf8, 0x5d, 0x06, 0x5d, 0xd7, 0xa4, 0xe2, 0xb8, 0x72, 0x27, 0xf2, + 0x38, 0x2b, 0x44, 0x4b, 0xf5, 0xd2, 0x29, 0x60, 0x70, 0x3c, 0xdc, + 0x86, 0xc0, 0xef, 0xd2, 0xd3, 0x4d, 0x5d, 0xe1, 0xdb, 0x26, }; /* see ee_dsa_alg_t in ee_bench.h */ -uint8_t *g_public_keys[] = { - g_ecc_public_key_p256r1, - g_ecc_public_key_p384, - g_ecc_public_key_c25519, - g_ecc_public_key_ed25519, - g_rsa_public_key_2048, - g_rsa_public_key_3072, - g_rsa_public_key_4096, +const uint8_t *g_public_keys[] = { + g_ecc_public_key_prime256v1_der, g_ecc_public_key_secp384r1_der, + g_ecc_public_key_c25519, g_ecc_public_key_ed25519_der, + g_rsa_public_key_2048_der, g_rsa_public_key_3072_der, + g_rsa_public_key_4096_der, }; /* see ee_dsa_alg_t in ee_bench.h */ -uint32_t g_public_key_sizes[] = { - 64 + 1, - 96 + 1, - 32, +const uint32_t g_public_key_sizes[] = { + g_ecc_public_key_prime256v1_der_len, + g_ecc_public_key_secp384r1_der_len, 32, - /* Yes, these are ASN.1 so we could extract size, but this is quicker. */ - 294, - 422, - 550, + g_ecc_public_key_ed25519_der_len, + g_rsa_public_key_2048_der_len, + g_rsa_public_key_3072_der_len, + g_rsa_public_key_4096_der_len, }; /* see ee_dsa_alg_t in ee_bench.h */ -uint8_t *g_dsa_signatures[] = { - g_ecc_signature_p256r1, - g_ecc_signature_p384, +const uint8_t *g_dsa_signatures[] = { + g_ecc_signature_prime256v1_sig, + g_ecc_signature_secp384r1_sig, 0, - g_ecc_signature_ed25519, - g_rsa_sig_2048, - g_rsa_sig_3072, - g_rsa_sig_4096, + g_ecc_signature_ed25519_sig, + g_rsa_sig_2048_der, + g_rsa_sig_3072_der, + g_rsa_sig_4096_der, }; /* see ee_dsa_alg_t in ee_bench.h */ -uint32_t g_dsa_signature_sizes[] = { - 71, - 104, +const uint32_t g_dsa_signature_sizes[] = { + g_ecc_signature_prime256v1_sig_len, + g_ecc_signature_secp384r1_sig_len, 0, - 64, - 256, - 384, - 512 + g_ecc_signature_ed25519_sig_len, + g_rsa_sig_2048_der_len, + g_rsa_sig_3072_der_len, + g_rsa_sig_4096_der_len, }; -// clang-format on +uint8_t g_dsa_message[] = { +#if 1 + /* SHA256(`Tempus unum hominem manet.`) */ + 0xb7, 0x03, 0xb9, 0xc0, 0x84, 0xbe, 0xe8, 0xa2, 0x78, 0xa9, 0x56, + 0x53, 0x48, 0x44, 0xd7, 0xfa, 0x40, 0x10, 0xa5, 0x86, 0x8c, 0x0c, + 0x82, 0xa4, 0x50, 0x6b, 0xf8, 0x1c, 0x36, 0x21, 0x8d, 0xe1, +#else + 0x54,0x65,0x6d,0x70,0x75,0x73,0x20,0x75,0x6e,0x75,0x6d,0x20,0x68,0x6f,0x6d,0x69, + 0x6e,0x65,0x6d,0x20,0x6d,0x61,0x6e,0x65,0x74,0x2e, +#endif +}; #endif /* __KEYS_H */ diff --git a/examples/selfhosted/main.c b/examples/selfhosted/main.c index 67e82ee..98060b2 100644 --- a/examples/selfhosted/main.c +++ b/examples/selfhosted/main.c @@ -612,7 +612,7 @@ wrap_variation_001(void *ex, uint32_t n, uint32_t i, wres_t *res) { ee_bench_result_t bres; n = 0; /* unused */ - ee_bench_var01(0, &bres); + ee_bench_var01(i, &bres); res->iter = bres.iter; res->dt = bres.dt; /** @@ -670,8 +670,8 @@ static task_entry_t g_task[] = TASK(aes128_ccm_encrypt , 52, 1.0f, 0xd82d) TASK(aes128_ccm_decrypt , 168, 1.0f, 0x9a42) TASK(ecdh_p256r1 , 0, 1.0f, 0) - TASK(ecdsa_sign_p256r1 , 32, 1.0f, 0) - TASK(ecdsa_verify_p256r1 , 32, 1.0f, 1) + TASK(ecdsa_sign_p256r1 , 0, 1.0f, 0) + TASK(ecdsa_verify_p256r1 , 0, 1.0f, 1) TASK(sha256 , 23, 3.0f, 0x2151) TASK(sha256 , 57, 1.0f, 0x3b3c) TASK(sha256 , 384, 1.0f, 0x1d3f) @@ -687,8 +687,8 @@ static task_entry_t g_task[] = TASKEX(sha256 , 1.0f, 0x5c37, &g_sha_digest_l) TASKEX(chachapoly_encrypt , 1.0f, 0xb645, &g_aead_e_multi_l) TASKEX(chachapoly_decrypt , 1.0f, 0x7b1a, &g_aead_d_multi_l) - TASK(ecdsa_sign_ed25519 , 130, 1.0f, 0) - TASK(ecdsa_verify_ed25519 , 64, 2.0f, 1) + TASK(ecdsa_sign_ed25519 , 0, 1.0f, 0) + TASK(ecdsa_verify_ed25519 , 0, 2.0f, 1) TASK(ecdh_x25519 , 0, 1.0f, 0) TASK(nop , 0, 0.0f, 0) /* sic. DSA SHA placeholder */ /* Secure Boot, RSA */ @@ -707,8 +707,8 @@ static task_entry_t g_task[] = TASKEX(sha256 , 3.0f, 0xa23c, &g_sha_digest_m) TASKEX(aes128_ccm_encrypt , 1.0f, 0xb9d9, &g_aead_e_multi_m) TASKEX(aes128_ccm_decrypt , 1.0f, 0x7b96, &g_aead_d_multi_m) - TASK(ecdsa_sign_p256r1 , 32, 1.0f, 0) - TASK(ecdsa_verify_p256r1 , 32, 2.0f, 1) + TASK(ecdsa_sign_p256r1 , 0, 1.0f, 0) + TASK(ecdsa_verify_p256r1 , 0, 2.0f, 1) TASK(ecdh_p256r1 , 0, 1.0f, 0) TASK(sha256 , 152, 8.0f, 0xd3ea) /* TLS1.3/GCM */ @@ -718,18 +718,18 @@ static task_entry_t g_task[] = TASKEX(sha256 , 1.0f, 0xa23c, &g_sha_digest_m) TASKEX(aes128_gcm_encrypt , 1.0f, 0x954b, &g_aead_e_multi_m) TASKEX(aes128_gcm_decrypt , 1.0f, 0x7b96, &g_aead_d_multi_m) - TASK(ecdsa_sign_p256r1 , 32, 1.0f, 0) - TASK(ecdsa_verify_p256r1 , 32, 2.0f, 1) + TASK(ecdsa_sign_p256r1 , 0, 1.0f, 0) + TASK(ecdsa_verify_p256r1 , 0, 2.0f, 1) TASK(ecdh_p256r1 , 0, 1.0f, 0) TASK(sha256 , 152, 8.0f, 0xd3ea) /* Secure Boot, RSA */ TASK(nop , 0, 0.0f, 0) /* math placeholder */ TASK(sha256 , 2048, 20.0f, 0x39ec) - TASK(rsa_verify_2048 , 32, 1.0f, 1) + TASK(rsa_verify_2048 , 0, 1.0f, 1) /* Secure Boot, ECC */ TASK(nop , 0, 0.0f, 0) /* math placeholder */ TASK(sha256 , 2048, 20.0f, 0x39ec) - TASK(ecdsa_verify_p256r1 , 32, 1.0f, 1) + TASK(ecdsa_verify_p256r1 , 0, 1.0f, 1) /* High */ /* TLS1.3/CCM */ TASK(sha384 , 182, 10.0f, 0x4505) @@ -738,8 +738,8 @@ static task_entry_t g_task[] = TASKEX(sha384 , 1.0f, 0xa6b6, &g_sha_digest_h) TASKEX(aes256_ccm_encrypt , 1.0f, 0xf16d, &g_aead_e_multi_h) TASKEX(aes256_ccm_decrypt , 1.0f, 0x56f1, &g_aead_d_multi_h) - TASK(ecdsa_sign_p384r1 , 48, 1.0f, 0) - TASK(ecdsa_verify_p384r1 , 48, 2.0f, 1) + TASK(ecdsa_sign_p384r1 , 0, 1.0f, 0) + TASK(ecdsa_verify_p384r1 , 0, 2.0f, 1) TASK(ecdh_p384r1 , 0, 1.0f, 0) TASK(sha384 , 173, 1.0f, 0x7bf9) /* TLS1.3/GCM */ @@ -749,18 +749,18 @@ static task_entry_t g_task[] = TASKEX(sha384 , 1.0f, 0xa6b6, &g_sha_digest_h) TASKEX(aes256_gcm_encrypt , 1.0f, 0x9f97, &g_aead_e_multi_h) TASKEX(aes256_gcm_decrypt , 1.0f, 0x56f1, &g_aead_d_multi_h) - TASK(ecdsa_sign_p384r1 , 48, 1.0f, 0) - TASK(ecdsa_verify_p384r1 , 48, 2.0f, 1) + TASK(ecdsa_sign_p384r1 , 0, 1.0f, 0) + TASK(ecdsa_verify_p384r1 , 0, 2.0f, 1) TASK(ecdh_p384r1 , 0, 1.0f, 0) TASK(sha384 , 173, 1.0f, 0x7bf9) /* Secure Boot, RSA */ TASK(aes256_ctr_decrypt , 2048, 20.0f, 0xd203) TASK(sha384 , 2048, 20.0f, 0xff90) - TASK(rsa_verify_4096 , 32, 1.0f, 1) + TASK(rsa_verify_4096 , 0, 1.0f, 1) /* Secure Boot, ECC */ TASK(aes256_ctr_decrypt , 2048, 20.0f, 0xd203) TASK(sha384 , 2048, 20.0f, 0xff90) - TASK(ecdsa_verify_p384r1 , 32, 1.0f, 1) + TASK(ecdsa_verify_p384r1 , 0, 1.0f, 1) }; static const size_t g_numtasks = sizeof(g_task) / sizeof(task_entry_t); /* This is how we scale the final score for each group*/ @@ -771,18 +771,18 @@ static struct scalar_tuples unsigned int scalar; float score; } g_scalars[] = { - { "TLSv1.2", 14, 1000, 0.0f }, - { "TLSv1.3_Light", 10, 10, 0.0f }, - { "Boot_Light", 3, 1, 0.0f }, - { "", 3, 0, 0.0f }, - { "TLSv1.3_Med_CCM", 10, 10, 0.0f }, - { "TLSv1.3_Med_GCM", 10, 10, 0.0f }, + { "TLSv1.2", 14, 1000, 0.0f }, + { "TLSv1.3_Light", 10, 10, 0.0f }, + { "Boot_Light", 3, 1, 0.0f }, + { "", 3, 0, 0.0f }, + { "TLSv1.3_Med_CCM", 10, 10, 0.0f }, + { "TLSv1.3_Med_GCM", 10, 10, 0.0f }, { "Boot_Med_RSA", 3, 1, 0.0f }, - { "Boot_Med_ECC", 3, 1, 0.0f }, + { "Boot_Med_ECC", 3, 1, 0.0f }, { "TLSv1.3_Heavy_CCM", 10, 10, 0.0f }, - { "TLSv1.3_Heavy_GCM", 10, 10, 0.0f }, - { "Boot_Heavy_RSA", 3, 1, 0.0f }, - { "Boot_Heavy_ECC", 3, 1, 0.0f }, + { "TLSv1.3_Heavy_GCM", 10, 10, 0.0f }, + { "Boot_Heavy_RSA", 3, 1, 0.0f }, + { "Boot_Heavy_ECC", 3, 1, 0.0f }, { NULL, 0, 0, 0.0f } /* Done */ }; // clang-format on @@ -877,10 +877,10 @@ main(void) g_task[i].expected_crc, g_task[i].actual_crc); } -#if DEBUG_VERIFY == 0 && CRC_ONLY == 0 printf("\n"); -#endif +#if DEBUG_VERIFY == 0 } +#endif } #if DEBUG_VERIFY == 0 && CRC_ONLY == 0 printf("\nComputing suite scores...\n\n"); diff --git a/examples/selfhosted/profile/wolfssl_th_api/th_ecdsa.c b/examples/selfhosted/profile/wolfssl_th_api/th_ecdsa.c index 52fa4e4..b1e370a 100644 --- a/examples/selfhosted/profile/wolfssl_th_api/th_ecdsa.c +++ b/examples/selfhosted/profile/wolfssl_th_api/th_ecdsa.c @@ -15,6 +15,7 @@ #include #include #include +#include /* can be set for static memory use */ #define HEAP_HINT NULL @@ -92,8 +93,8 @@ th_ecdsa_create(void **pp_context, ee_ecc_group_t group) ee_status_t th_ecdsa_sign(void *p_context, - uint8_t *p_msg, - uint32_t msglen, + uint8_t *p_hash, + uint32_t hashlen, uint8_t *p_sig, uint32_t *p_siglen) { @@ -104,12 +105,19 @@ th_ecdsa_sign(void *p_context, { case ECC_SECP256R1: case ECC_SECP384R1: - CHK1(wc_ecc_sign_hash( - p_msg, msglen, p_sig, p_siglen, &(c->rng), &(c->key.ecc))); + CHK1(wc_SignatureGenerateHash(WC_HASH_TYPE_SHA256, + WC_SIGNATURE_TYPE_ECC, + p_hash, + hashlen, + p_sig, + p_siglen, + &(c->key.ecc), + sizeof(ecc_key), + &(c->rng))); break; case ECC_X25519: CHK1(wc_ed25519_sign_msg( - p_msg, msglen, p_sig, p_siglen, &(c->key.ed25519))); + p_hash, hashlen, p_sig, p_siglen, &(c->key.ed25519))); break; default: th_printf("e-[th_ecdsa_sign: invalid curve %d]\r\n", c->curve); @@ -123,8 +131,8 @@ th_ecdsa_sign(void *p_context, ee_status_t th_ecdsa_verify(void *p_context, - uint8_t *p_msg, - uint32_t msglen, + uint8_t *p_hash, + uint32_t hashlen, uint8_t *p_sig, uint32_t siglen, bool *p_pass) @@ -138,12 +146,27 @@ th_ecdsa_verify(void *p_context, { case ECC_SECP256R1: case ECC_SECP384R1: - CHK1(wc_ecc_verify_hash( - p_sig, siglen, p_msg, msglen, &verify, &(c->key.ecc))); + ret = wc_SignatureVerifyHash(WC_HASH_TYPE_SHA256, + WC_SIGNATURE_TYPE_ECC, + p_hash, + hashlen, + p_sig, + siglen, + &(c->key.ecc), + sizeof(ecc_key)); + if (ret != 0 && ret != SIG_VERIFY_E) + { + th_printf("e-[wc_SignatureVerifyHash: %d]\r\n", ret); + return EE_STATUS_ERROR; + } + if (ret == 0) + { + verify = 1; + } break; case ECC_X25519: ret = wc_ed25519_verify_msg( - p_sig, siglen, p_msg, msglen, &verify, &(c->key.ed25519)); + p_sig, siglen, p_hash, hashlen, &verify, &(c->key.ed25519)); if (ret != 0 && ret != SIG_VERIFY_E) { th_printf("e-[wc_ed25519_verify_msg: %d]\r\n", ret); @@ -156,9 +179,6 @@ th_ecdsa_verify(void *p_context, } *p_pass = verify == 1; return EE_STATUS_OK; -error: - th_printf("e-[th_ecdsa_verify: error: %d]\r\n", ret); - return EE_STATUS_ERROR; } ee_status_t diff --git a/examples/selfhosted/profile/wolfssl_th_api/th_rsa.c b/examples/selfhosted/profile/wolfssl_th_api/th_rsa.c index 182ae15..a6bb7a0 100644 --- a/examples/selfhosted/profile/wolfssl_th_api/th_rsa.c +++ b/examples/selfhosted/profile/wolfssl_th_api/th_rsa.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include /* can be set for static memory use */ #define HEAP_HINT NULL @@ -91,39 +93,56 @@ th_rsa_set_public_key(void *p_context, const uint8_t *p_pub, uint32_t publen) ee_status_t th_rsa_verify(void *p_context, - uint8_t *p_msg, - uint32_t msglen, + uint8_t *p_hash, + uint32_t hashlen, uint8_t *p_sig, uint32_t siglen, bool *p_pass) { - rsa_context_t *ctx = (rsa_context_t *)p_context; - ee_status_t status = EE_STATUS_ERROR; - int ret = 0; - uint32_t diglen = msglen; - uint8_t *p_digest = NULL; - - *p_pass = false; - p_digest = XMALLOC(msglen, HEAP_HINT, DYNAMIC_TYPE_RSA_BUFFER); - if (!p_digest) + rsa_context_t *ctx = (rsa_context_t *)p_context; + int ret = 0; + uint8_t encoded_hash[100]; /* should be around 50 bytes */ + uint32_t encoded_size; + + *p_pass = false; + + /* Add ASN digest info header */ + ret = wc_EncodeSignature( + encoded_hash, + p_hash, + hashlen, + SHA256h + ); + + if (ret < 0) { - th_printf("e-[th_rsa_verify: XMALLOC failed]\r\n"); + th_printf("e-[wc_EncodeSignature: %d]\r\n", ret); return EE_STATUS_ERROR; } - ret = wc_RsaSSL_Verify(p_sig, siglen, p_digest, diglen, ctx->pubkey); - if (ret < 0) + + encoded_size = (uint32_t)ret; + + ret = wc_SignatureVerifyHash(WC_HASH_TYPE_SHA256, + WC_SIGNATURE_TYPE_RSA_W_ENC, + encoded_hash, + encoded_size, + p_sig, + siglen, + ctx->pubkey, + sizeof(RsaKey)); + + if (ret != 0 && ret != SIG_VERIFY_E) { - th_printf("e-[wc_RsaSSL_Verify: %d]\r\n", ret); - goto exit; + th_printf("e-[wc_SignatureVerifyHash: %d]\r\n", ret); + return EE_STATUS_ERROR; } - if (!XMEMCMP(p_msg, p_digest, msglen) && ret == msglen) + + if (ret == 0) { *p_pass = true; } - status = EE_STATUS_OK; -exit: - XFREE(p_digest, HEAP_HINT, DYNAMIC_TYPE_RSA_BUFFER); - return status; + + return EE_STATUS_OK; } void diff --git a/profile/ee_ecdsa.h b/profile/ee_ecdsa.h index cbb6efb..269c73f 100644 --- a/profile/ee_ecdsa.h +++ b/profile/ee_ecdsa.h @@ -42,37 +42,44 @@ ee_status_t th_ecdsa_create(void **pp_context, ee_ecc_group_t group); * contain the length of the signature. * * @param p_context - The context from the `create` function - * @param p_msg - The hashed buffer to sign - * @param msglen - Length of the hashed buffer + * @param p_hash - The hashed buffer to sign + * @param hashlen - Length of the hashed buffer * @param p_sig - The output signature buffer (provided) * @param p_siglen - The number of bytes used in the output signature buffer. * @return ee_status_t - EE_STATUS_OK or EE_STATUS_ERROR */ ee_status_t th_ecdsa_sign(void *p_context, - uint8_t *p_msg, - uint32_t msglen, + uint8_t *p_hash, + uint32_t hashlen, uint8_t *p_sig, uint32_t *p_siglen); /** * @brief Verify a message (hash) with the public key. + * + * For EcDSA, the signature format is the ASN.1 DER of R and S. For Ed25519, + * the signature is the raw, little endian encoding of R and S, padded to 256 + * bits. * + * Note that even if the message is a hash, Ed25519 will perform another SHA- + * 512 operation on it, as this is part of RFC 8032. + * * It will return EE_STATUS_OK on message verify, and EE_STATUS_ERROR if the * message does not verify, or if there is some other error (which shall * be reported with `th_printf("e-[....]r\n");`. * * @param p_context - The context from the `create` function * @param group - See the `ee_ecc_group_t` enum - * @param p_msg - The message buffer to verify - * @param msglen - Length of the message buffer + * @param p_hash - The message buffer to verify + * @param hashlen - Length of the message buffer * @param p_sig - The input signature buffer * @param siglen - Length of the input signature buffer * @param p_pass - Did the message verify? * @return ee_status_t - see above. */ ee_status_t th_ecdsa_verify(void *p_context, - uint8_t *p_msg, - uint32_t msglen, + uint8_t *p_hash, + uint32_t hashlen, uint8_t *p_sig, uint32_t siglen, bool *p_pass); diff --git a/profile/ee_rsa.h b/profile/ee_rsa.h index d60dd3f..cf55b5a 100644 --- a/profile/ee_rsa.h +++ b/profile/ee_rsa.h @@ -46,12 +46,16 @@ ee_status_t th_rsa_set_public_key(void *p_context, uint32_t publen); /** - * @brief Verify a message (hash) with the public key. The message will - * be in ASN.1 format as OID || SHA256(m) + * @brief Verify a message (hash) with the public key. The signature will + * be in ASN.1 padded OID || SHA256(m). + * + * It will return EE_STATUS_OK on message verify, and EE_STATUS_ERROR if the + * message does not verify, or if there is some other error (which shall + * be reported with `th_printf("e-[....]r\n");`. * * @param p_context - The context from the `create` function - * @param p_sig - The input message buffer - * @param msglen - Length of the input message buffer + * @param p_hash - The input message buffer + * @param hashlen - Length of the input message buffer * @param p_sig - The output signature buffer * @param siglen - Length of the output signature buffer * @param p_pass - Did the message verify? @@ -59,7 +63,7 @@ ee_status_t th_rsa_set_public_key(void *p_context, */ ee_status_t th_rsa_verify(void *p_context, uint8_t *p_msg, - uint32_t msglen, + uint32_t hashlen, uint8_t *p_sig, uint32_t siglen, bool *p_pass); diff --git a/profile/th_api/th_ecdsa.c b/profile/th_api/th_ecdsa.c index 59838ba..053df71 100644 --- a/profile/th_api/th_ecdsa.c +++ b/profile/th_api/th_ecdsa.c @@ -28,8 +28,8 @@ th_ecdsa_get_public_key(void *p_context, uint8_t *p_out, uint32_t *p_outlen) ee_status_t th_ecdsa_verify(void *p_context, - uint8_t *p_msg, - uint32_t msglen, + uint8_t *p_hash, + uint32_t hashlen, uint8_t *p_sig, uint32_t siglen, bool *p_pass) @@ -40,8 +40,8 @@ th_ecdsa_verify(void *p_context, ee_status_t th_ecdsa_sign(void *p_context, - uint8_t *p_msg, - uint32_t msglen, + uint8_t *p_hash, + uint32_t hashlen, uint8_t *p_sig, uint32_t *p_siglen) { diff --git a/profile/th_api/th_rsa.c b/profile/th_api/th_rsa.c index 96ec841..051713d 100644 --- a/profile/th_api/th_rsa.c +++ b/profile/th_api/th_rsa.c @@ -31,10 +31,10 @@ th_rsa_set_public_key(void *p_context, const uint8_t *p_pub, uint32_t publen) ee_status_t th_rsa_verify(void *p_context, - uint8_t *p_msg, - uint32_t mlen, + uint8_t *p_hash, + uint32_t hashlen, uint8_t *p_sig, - uint32_t slen, + uint32_t siglen, bool *p_pass) { #warning "th_rsa_sign not implemented"