2014-01-09 7 views
0

Crypto ++를 사용하여 변수에 ECDSA 서명을 가져야합니다.
SignMessage를 시작한 후에 가져 오려고했지만 서명이 비어 있습니다.
어떻게받을 수 있습니까?Crypto ++로 ECDSA 서명 받기

답변

0

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) {...} 

Verifcation이 실패 할 경우 다음을 시도하십시오.

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 
); 
관련 문제