0
我必須在使用Crypto ++的變量中獲得ECDSA簽名。
我試圖在啓動SignMessage後得到它,但簽名爲空。
我怎麼能得到它?使用Crypto ++獲取ECDSA簽名
我必須在使用Crypto ++的變量中獲得ECDSA簽名。
我試圖在啓動SignMessage後得到它,但簽名爲空。
我怎麼能得到它?使用Crypto ++獲取ECDSA簽名
你有沒有看過Crypto ++ wiki? Elliptic Curve Digital Signature Algorithm上有很多東西。
其真不明白你在做什麼或那裏的東西出了問題,所以這裏的副本,並從維基粘貼:
簽名:
ECDSA<ECP, SHA1>::PrivateKey privateKey;
privateKey.Load(...);
AutoSeededRandomPool prng;
string message = "Yoda said, Do or do not. There is no try.";
string signature;
StringSource ss1(message, true /*pump all*/,
new SignerFilter(prng,
ECDSA<ECP,SHA1>::Signer(privateKey),
new StringSink(signature)
) // SignerFilter
); // StringSource
驗證:
ECDSA<ECP, SHA1>::PublicKey publicKey;
publicKey.Load(...);
// Result of the verification process
bool result = false;
// Exactly what was signed in the previous step
string message = ...;
// Output from the signing operation in the previous step
string signature = ...;
StringSource ss2(signature+message, true /*pump all*/,
new SignatureVerificationFilter(
ECDSA<ECP,SHA1>::Verifier(publicKey),
new ArraySink((byte*)&result, sizeof(result))
) // SignatureVerificationFilter
);
// Verification failure?
if(!result) {...}
如果您想驗證失敗,請嘗試:
static const int VERIFICATION_FLAGS = SIGNATURE_AT_BEGIN | THROW_EXCEPTION;
StringSource ss3(signature+message, true /*pump all*/,
new SignatureVerificationFilter(
ECDSA<ECP,SHA1>::Verifier(publicKey),
NULL, /* No need for attached filter */
VERIFICATION_FLAGS
) // SignatureVerificationFilter
);