void ECP::EncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const { if (P.identity) NullStore().TransferTo(bt, EncodedPointSize(compressed)); else if (compressed) { bt.Put(2 + P.y.GetBit(0)); P.x.Encode(bt, GetField().MaxElementByteLength()); } else { unsigned int len = GetField().MaxElementByteLength(); bt.Put(4); // uncompressed P.x.Encode(bt, len); P.y.Encode(bt, len); } }
void EC2N::EncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const { if (P.identity) NullStore().TransferTo(bt, EncodedPointSize(compressed)); else if (compressed) { bt.Put(2 + (!P.x ? 0 : m_field->Divide(P.y, P.x).GetBit(0))); P.x.Encode(bt, m_field->MaxElementByteLength()); } else { unsigned int len = m_field->MaxElementByteLength(); bt.Put(4); // uncompressed P.x.Encode(bt, len); P.y.Encode(bt, len); } }
void EC2N::EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const { if (P.identity) memset(encodedPoint, 0, EncodedPointSize(compressed)); else if (compressed) { encodedPoint[0] = 2 + (!P.x ? 0 : m_field->Divide(P.y, P.x).GetBit(0)); P.x.Encode(encodedPoint+1, m_field->MaxElementByteLength()); } else { unsigned int len = m_field->MaxElementByteLength(); encodedPoint[0] = 4; // uncompressed P.x.Encode(encodedPoint+1, len); P.y.Encode(encodedPoint+1+len, len); } }
void EC2N::DEREncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const { SecByteBlock str(EncodedPointSize(compressed)); EncodePoint(str, P, compressed); DEREncodeOctetString(bt, str); }
void ECP::EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const { ArraySink sink(encodedPoint, EncodedPointSize(compressed)); EncodePoint(sink, P, compressed); assert(sink.TotalPutLength() == EncodedPointSize(compressed)); }
void EC2N::EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const { ArraySink sink(encodedPoint, EncodedPointSize(compressed)); EncodePoint(sink, P, compressed); CRYPTOPP_ASSERT(sink.TotalPutLength() == EncodedPointSize(compressed)); }