ByteSeq EC2OSP(const EC_Point & Point, EC::EC2OSP_COMPRESS_MODE mode) { const unsigned char tY = ((mode == EC::EC2OSP_COMPRESSED) || (mode == EC::EC2OSP_HYBRID)) ? EC_CPoint::compress_tY(Point) : 0; if (Point.isZero()) return ByteSeq(0); /* Pad - according to example of 2^m/ECNR. * Check this. Don't see much sense */ const long Pad = L(Point.getEC().getModulus()); const unsigned int U = ((mode == EC::EC2OSP_UNCOMPRESSED) || (mode == EC::EC2OSP_HYBRID)) ? 1 : 0; const unsigned int C = ((mode == EC::EC2OSP_COMPRESSED) || (mode == EC::EC2OSP_HYBRID)) ? 1 : 0; const ByteSeq X(FE2OSP(Point.getX(), Pad)); const ByteSeq H(FE2OSP(4*U+C*(2+tY))); if (U) return H || X || FE2OSP(Point.getY(), Pad); else return H || X; }
virtual bool setPublicKey(const Octet & PublicKey) { if (PublicKey.getDataSize() != ( _Lcm * 2 )) return false; tOS2FEP<typename EC_Dscr::aECP> OS2FEP; _Curve.enter_mod_context(EC_Dscr::aEC::FIELD_CONTEXT); _publicKey = toProjective(_Curve .create(OS2FEP(ByteSeq(PublicKey.getData(), _Lcm)), OS2FEP(ByteSeq(PublicKey.getData() + _Lcm, _Lcm))), _PCurve); _Curve.leave_mod_context(); _isPublicKeyLoaded = true; setPublicKeyHook(); return _isPublicKeyLoaded; }
/*! \brief Create a nonce. \returns Nonce. */ NZSPtr<ROAPNonce> OMADRMNonceCreator::CreateNonce() { nonce = nonce + "a"; Base64StringT tmp; Base64Factory::Encode(ByteSeq((ByteT*)nonce.data(), nonce.size()), tmp); return new ROAPNonce(tmp); }
/*! \brief Encode as byte array. Encode for purpose of stream encoding, signature verification etc. \param encoded output, encoded byte array. \returns Boolean indicating success or failure. */ bool NMACEncSecureContainerIPMPData::MPEG2Encode(ByteSeq& encoded) const { return IPMPData::MPEG2Encode(0x09, ByteSeq((ByteT)0x80) + encrypted.MPEG2Encode(), encoded); }
/*! \brief Encode as byte array. Encode for purpose of stream encoding, signature verification etc. \param encoded output, encoded byte array. \returns Boolean indicating success or failure. */ bool NMACNEncSecureContainerIPMPData::MPEG2Encode(ByteSeq& encoded) const { return IPMPData::MPEG2Encode(0x09, ByteSeq((ByteT)0x00) + message.MPEG2Encode(), encoded); }