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

Function SimpleKeyAgreementValidate

src/cryptopp/validat2.cpp:205–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205bool SimpleKeyAgreementValidate(SimpleKeyAgreementDomain &d)
206{
207 if (d.GetCryptoParameters().Validate(GlobalRNG(), 3))
208 cout << "passed simple key agreement domain parameters validation" << endl;
209 else
210 {
211 cout << "FAILED simple key agreement domain parameters invalid" << endl;
212 return false;
213 }
214
215 SecByteBlock priv1(d.PrivateKeyLength()), priv2(d.PrivateKeyLength());
216 SecByteBlock pub1(d.PublicKeyLength()), pub2(d.PublicKeyLength());
217 SecByteBlock val1(d.AgreedValueLength()), val2(d.AgreedValueLength());
218
219 d.GenerateKeyPair(GlobalRNG(), priv1, pub1);
220 d.GenerateKeyPair(GlobalRNG(), priv2, pub2);
221
222 memset(val1.begin(), 0x10, val1.size());
223 memset(val2.begin(), 0x11, val2.size());
224
225 if (!(d.Agree(val1, priv1, pub2) && d.Agree(val2, priv2, pub1)))
226 {
227 cout << "FAILED simple key agreement failed" << endl;
228 return false;
229 }
230
231 if (memcmp(val1.begin(), val2.begin(), d.AgreedValueLength()))
232 {
233 cout << "FAILED simple agreed values not equal" << endl;
234 return false;
235 }
236
237 cout << "passed simple key agreement" << endl;
238 return true;
239}
240
241bool AuthenticatedKeyAgreementValidate(AuthenticatedKeyAgreementDomain &d)
242{

Callers 5

ValidateDHFunction · 0.85
ValidateLUC_DHFunction · 0.85
ValidateXTR_DHFunction · 0.85
ValidateECPFunction · 0.85
ValidateEC2NFunction · 0.85

Calls 8

PrivateKeyLengthMethod · 0.80
PublicKeyLengthMethod · 0.80
GenerateKeyPairMethod · 0.80
ValidateMethod · 0.45
AgreedValueLengthMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
AgreeMethod · 0.45

Tested by

no test coverage detected