-
-
Save guidovranken/a96dec06d3bea9037bbf74bd7caca4d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define CF_CHECK_EQ(expr, res) if ( (expr) != (res) ) { goto end; } | |
#define CF_CHECK_NE(expr, res) if ( (expr) == (res) ) { goto end; } | |
void SymCryptFatal(UINT32 fatalCode) { | |
(void)fatalCode; | |
abort(); | |
} | |
void SymCryptInjectError( PBYTE pbData, SIZE_T cbData ) { | |
(void)pbData; | |
(void)cbData; | |
} | |
PVOID SymCryptCallbackAlloc( SIZE_T nBytes ) { | |
return malloc(nBytes); | |
} | |
VOID SymCryptCallbackFree( VOID * pMem ) { | |
free(pMem); | |
} | |
SYMCRYPT_ERROR SymCryptCallbackRandom(PBYTE pbBuffer, SIZE_T cbBuffer ) { | |
abort(); | |
} | |
SYMCRYPT_CPU_FEATURES | |
SymCryptCpuFeaturesNeverPresent(void) { | |
return 0; | |
} | |
int main(void) | |
{ | |
const unsigned char hash[] = {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}; | |
const unsigned char pub[] = {0x94, 0x7B, 0x9D, 0x3D, 0x56, 0x12, 0xDA, 0x44, 0x4B, 0x4D, 0xC5, 0x2D, 0xEF, 0x03, 0x45, 0xC6, 0xE7, 0xAC, 0xB3, 0x1D, 0xD6, 0xF4, 0xCD, 0xD0, 0x1B, 0x8D, 0x1E, 0xE1, 0x94, 0xD7, 0x82, 0x91, 0xDB, 0x7D, 0x7B, 0xA7, 0xEA, 0x1B, 0xE4, 0x94, 0x0C, 0xAB, 0x75, 0xD9, 0x94, 0xD6, 0x4D, 0xBA}; | |
const unsigned char sig[] = {0x5F, 0xED, 0x32, 0xB4, 0x9B, 0xE4, 0x32, 0xC8, 0x08, 0x56, 0xA5, 0x78, 0x86, 0x14, 0x79, 0xC6, 0x06, 0x28, 0x14, 0x9A, 0x64, 0xB6, 0x20, 0xB5, 0x3A, 0x95, 0x40, 0xB1, 0x7C, 0xA8, 0x64, 0x50, 0x12, 0x49, 0x7E, 0x11, 0x30, 0x71, 0x5D, 0xD5, 0xEA, 0xE1, 0xBB, 0x29, 0x52, 0x00, 0x02, 0x73}; | |
SYMCRYPT_ECURVE* curve = SymCryptEcurveAllocate(SymCryptEcurveParamsNistP192, 0); | |
SYMCRYPT_ECKEY* key = NULL; | |
const SYMCRYPT_ECURVE_PARAMS* curveParams = NULL; | |
CF_CHECK_NE(key = SymCryptEckeyAllocate(curve), NULL); | |
CF_CHECK_EQ(SymCryptEckeySetValue( | |
NULL, 0, | |
pub, sizeof(pub), | |
SYMCRYPT_NUMBER_FORMAT_MSB_FIRST, SYMCRYPT_ECPOINT_FORMAT_XY, | |
0, key), SYMCRYPT_NO_ERROR); | |
SymCryptEcDsaVerify( | |
key, | |
hash, | |
sizeof(hash), | |
sig, | |
sizeof(sig), | |
SYMCRYPT_NUMBER_FORMAT_MSB_FIRST, | |
0); | |
end: | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment