bool verify(CryptoPP::ECPPoint Q, byte *message, unsigned message_length, CryptoPP::Integer r, CryptoPP::Integer s){ auto ec = common::ec_parameters().GetCurve(); auto G = common::ec_parameters().GetSubgroupGenerator(); auto n = common::ec_parameters().GetGroupOrder(); Integer z = hash_m_to_int(message, message_length, n.ByteCount()); // verify if (Q == ec.Identity()){ cerr << "Q == O" << endl; return false; } if (!(ec.Multiply(n, Q) == ec.Identity())){ cerr << "n x Q != O" << endl; return false; } if (r <= 0 || r >= n){ cerr << "incorrect r" << endl; return false; } if (s <= 0 || s >= n){ cerr << "incorrect s" << endl; return false; } Integer w = s.InverseMod(n); Integer u1 = a_times_b_mod_c(z, w, n); Integer u2 = a_times_b_mod_c(r, w, n); ECPPoint P2 = ec.Add(ec.Multiply(u1, G), ec.Multiply(u2, Q)); if (P2.x != r){ cerr << "P2.x != r" << endl; return false; } return true; }
MALIB_API SURFACE::SURFACE(const string name, void* data, uint width, uint height, PIXELFORMAT format) { this->data = data; this->name = name; this->width = width; this->height = height; this->byteCount = ByteCount(format); this->format = format; }
MALIB_API SURFACE::SURFACE(const string name, uint width, uint height, PIXELFORMAT format) { this->data = 0; this->name = name; this->width = width; this->height = height; this->format = format; this->byteCount = ByteCount(format); uint size = this->width * this->height * this->byteCount; this->data = new uchar[size]; memset((void*)this->data, 0, size * sizeof(uchar)); }
TUint64 CSISController::ControllerSizeForHash() const { TUint64 ctlSize = ByteCount(false); TUint64 size = ctlSize - iSignatures.ByteCountWithHeader(false) - iDataIndex.ByteCountWithHeader(false); if(CSISHeader::IsBigHeader(ctlSize)) { size += 8; } else { size += 4; } return size; }
/** * Creates a new buffer containing the big-endian binary representation of this * integer. * * Note that it does not support the exporting of negative integers. * * @return The new buffer. * * @leave KErrNegativeExportNotSupported If this instance is a negative integer. * */ EXPORT_C HBufC8* TInteger::BufferLC() const { if(IsNegative()) { User::Leave(KErrNegativeExportNotSupported); } TUint bytes = ByteCount(); HBufC8* buf = HBufC8::NewMaxLC(bytes); TUint8* bufPtr = (TUint8*)(buf->Ptr()); TUint8* regPtr = (TUint8*)Ptr(); // we internally store the number little endian, as a string we want it big // endian for(TUint i=0,j=bytes-1; i<bytes; ) { bufPtr[i++] = regPtr[j--]; } return buf; }