CryptoSys PKI Pro Manual

ECC_KeyMatch

Verifies that a pair of "internal" ECC private and public key strings are matched.

VBA/VB6 Syntax

Public Declare Function ECC_KeyMatch Lib "diCrPKI.dll" (ByVal strPrivateKey As String, ByVal strPublicKey As String) As Long

nRet = ECC_KeyMatch(strPrivateKey, strPublicKey)

C/C++ Syntax

long __stdcall ECC_KeyMatch(const char *szPrivateKey, const char *szPublicKey);

Parameters

szPrivateKey
[in] containing an "internal" ECC private key string.
szPublicKey
[in] containing an "internal" ECC public key string.

Returns (VBA/C)

If the pair of private and public keys match, the return value is zero (0). If the key strings are valid but not matched, the return value is NO_MATCH_ERROR (-21). If an error occurs, it returns a nonzero error code.

.NET Equivalent

Ecc.KeyMatch Method

Python Equivalent

static Ecc.key_match(prikeystr, pubkeystr)

C++ (STL) Equivalent

static bool dipki::Ecc::KeyMatch (const std::string &privateKey, const std::string &publicKey)

Remarks

This function allows you to check that a private key file is matched with its corresponding public key. You must read the keys into "internal" key strings before comparing. Note that the return value for success is zero.

Example

Dim strCurveName As String
Dim strPriKeyHex As String
Dim strPubKeyHex As String
Dim strPriKeyInt As String
Dim strPubKeyInt As String
Dim r As Long

' Ref: https://www.ietf.org/archive/id/draft-ietf-cose-cbor-encoded-cert-20.html#appendix-A.1.4
strCurveName = "secp256r1"
strPriKeyHex = "DC66B3415456D649429B53223DF7532B942D6B0E0842C30BCA4C0ACF91547BB2"
strPubKeyHex = "02AE4CDB01F614DEFC7121285FDC7F5C6D1D42C95647F061BA0080DF678867845E"
' Read in keys to ephemeral internal representation
strPriKeyInt = eccReadKeyByCurve(strPriKeyHex, strCurveName)
strPubKeyInt = eccReadKeyByCurve(strPubKeyHex, strCurveName)
' Check that keys match
r = ECC_KeyMatch(strPriKeyInt, strPubKeyInt)
Debug.Print "ECC_KeyMatch returns " & r & " (expected 0)"
Debug.Assert r = 0
ECC_KeyMatch returns 0 (expected 0)

See Also

ECC_KeyHashCode

[Contents] [Index]

[PREV: ECC_DHSharedSecret...]   [Contents]   [Index]   
   [NEXT: ECC_KeyHashCode...]

Copyright © 2004-26 D.I. Management Services Pty Ltd t/a CryptoSys. All rights reserved. Generated 2026-09-06T00:43:03Z.