MCPcopy Create free account
hub / github.com/LUX-Core/lux / SignatureValidate

Function SignatureValidate

src/cryptopp/validat2.cpp:128–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128bool SignatureValidate(PK_Signer &priv, PK_Verifier &pub, bool thorough = false)
129{
130 bool pass = true, fail;
131
132 fail = !pub.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2) || !priv.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2);
133 pass = pass && !fail;
134
135 cout << (fail ? "FAILED " : "passed ");
136 cout << "signature key validation\n";
137
138 const byte *message = (byte *)"test message";
139 const int messageLen = 12;
140
141 SecByteBlock signature(priv.MaxSignatureLength());
142 size_t signatureLength = priv.SignMessage(GlobalRNG(), message, messageLen, signature);
143 fail = !pub.VerifyMessage(message, messageLen, signature, signatureLength);
144 pass = pass && !fail;
145
146 cout << (fail ? "FAILED " : "passed ");
147 cout << "signature and verification\n";
148
149 ++signature[0];
150 fail = pub.VerifyMessage(message, messageLen, signature, signatureLength);
151 pass = pass && !fail;
152
153 cout << (fail ? "FAILED " : "passed ");
154 cout << "checking invalid signature" << endl;
155
156 if (priv.MaxRecoverableLength() > 0)
157 {
158 signatureLength = priv.SignMessageWithRecovery(GlobalRNG(), message, messageLen, NULL, 0, signature);
159 SecByteBlock recovered(priv.MaxRecoverableLengthFromSignatureLength(signatureLength));
160 DecodingResult result = pub.RecoverMessage(recovered, NULL, 0, signature, signatureLength);
161 fail = !(result.isValidCoding && result.messageLength == messageLen && memcmp(recovered, message, messageLen) == 0);
162 pass = pass && !fail;
163
164 cout << (fail ? "FAILED " : "passed ");
165 cout << "signature and verification with recovery" << endl;
166
167 ++signature[0];
168 result = pub.RecoverMessage(recovered, NULL, 0, signature, signatureLength);
169 fail = result.isValidCoding;
170 pass = pass && !fail;
171
172 cout << (fail ? "FAILED " : "passed ");
173 cout << "recovery with invalid signature" << endl;
174 }
175
176 return pass;
177}
178
179bool CryptoSystemValidate(PK_Decryptor &priv, PK_Encryptor &pub, bool thorough = false)
180{

Callers 11

ValidateNRFunction · 0.85
ValidateDSAFunction · 0.85
ValidateLUCFunction · 0.85
ValidateLUC_DLFunction · 0.85
ValidateRabinFunction · 0.85
ValidateRWFunction · 0.85
ValidateECPFunction · 0.85
ValidateEC2NFunction · 0.85
ValidateECDSAFunction · 0.85
ValidateECGDSAFunction · 0.85
ValidateESIGNFunction · 0.85

Calls 6

MaxRecoverableLengthMethod · 0.80
RecoverMessageMethod · 0.80
ValidateMethod · 0.45
SignMessageMethod · 0.45
VerifyMessageMethod · 0.45

Tested by

no test coverage detected