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

Method BERDecodePrivateKey

src/cryptopp/eccrypto.cpp:669–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

667
668template <class EC>
669void DL_PrivateKey_EC<EC>::BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
670{
671 CRYPTOPP_UNUSED(size);
672 BERSequenceDecoder seq(bt);
673 word32 version;
674 BERDecodeUnsigned<word32>(seq, version, INTEGER, 1, 1); // check version
675
676 BERGeneralDecoder dec(seq, OCTET_STRING);
677 if (!dec.IsDefiniteLength())
678 BERDecodeError();
679 Integer x;
680 x.Decode(dec, (size_t)dec.RemainingLength());
681 dec.MessageEnd();
682 if (!parametersPresent && seq.PeekByte() != (CONTEXT_SPECIFIC | CONSTRUCTED | 0))
683 BERDecodeError();
684 if (!seq.EndReached() && seq.PeekByte() == (CONTEXT_SPECIFIC | CONSTRUCTED | 0))
685 {
686 BERGeneralDecoder parameters(seq, CONTEXT_SPECIFIC | CONSTRUCTED | 0);
687 this->AccessGroupParameters().BERDecode(parameters);
688 parameters.MessageEnd();
689 }
690 if (!seq.EndReached())
691 {
692 // skip over the public element
693 SecByteBlock subjectPublicKey;
694 unsigned int unusedBits;
695 BERGeneralDecoder publicKey(seq, CONTEXT_SPECIFIC | CONSTRUCTED | 1);
696 BERDecodeBitString(publicKey, subjectPublicKey, unusedBits);
697 publicKey.MessageEnd();
698 Element Q;
699 if (!(unusedBits == 0 && this->GetGroupParameters().GetCurve().DecodePoint(Q, subjectPublicKey, subjectPublicKey.size())))
700 BERDecodeError();
701 }
702 seq.MessageEnd();
703
704 this->SetPrivateExponent(x);
705}
706
707template <class EC>
708void DL_PrivateKey_EC<EC>::DEREncodePrivateKey(BufferedTransformation &bt) const

Callers

nothing calls this directly

Calls 10

BERDecodeErrorFunction · 0.85
BERDecodeBitStringFunction · 0.85
MessageEndMethod · 0.80
PeekByteMethod · 0.80
EndReachedMethod · 0.80
SetPrivateExponentMethod · 0.80
DecodeMethod · 0.45
BERDecodeMethod · 0.45
DecodePointMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected