diff --git a/embeddedcryptopp/algebra.cpp b/embeddedcryptopp/algebra.cpp
index 78c3947..b8818e6 100644
|
a
|
b
|
template <class T> const T& AbstractEuclideanDomain<T>::Gcd(const Element &a, co |
| 58 | 58 | Element g[3]={b, a}; |
| 59 | 59 | unsigned int i0=0, i1=1, i2=2; |
| 60 | 60 | |
| 61 | | while (!Equal(g[i1], this->Identity())) |
| | 61 | while (!this->Equal(g[i1], this->Identity())) |
| 62 | 62 | { |
| 63 | 63 | g[i2] = Mod(g[i0], g[i1]); |
| 64 | 64 | unsigned int t = i0; i0 = i1; i1 = i2; i2 = t; |
diff --git a/embeddedcryptopp/eccrypto.cpp b/embeddedcryptopp/eccrypto.cpp
index fd8462f..922104c 100644
|
a
|
b
|
template <class EC> void DL_GroupParameters_EC<EC>::Initialize(const OID &oid) |
| 435 | 435 | StringSource ssG(param.g, true, new HexDecoder); |
| 436 | 436 | Element G; |
| 437 | 437 | bool result = GetCurve().DecodePoint(G, ssG, (size_t)ssG.MaxRetrievable()); |
| 438 | | SetSubgroupGenerator(G); |
| | 438 | this->SetSubgroupGenerator(G); |
| 439 | 439 | assert(result); |
| 440 | 440 | |
| 441 | 441 | StringSource ssN(param.n, true, new HexDecoder); |
| … |
… |
bool DL_GroupParameters_EC<EC>::ValidateElement(unsigned int level, const Elemen |
| 591 | 591 | if (level >= 2 && pass) |
| 592 | 592 | { |
| 593 | 593 | const Integer &q = GetSubgroupOrder(); |
| 594 | | Element gq = gpc ? gpc->Exponentiate(this->GetGroupPrecomputation(), q) : ExponentiateElement(g, q); |
| | 594 | Element gq = gpc ? gpc->Exponentiate(this->GetGroupPrecomputation(), q) : this->ExponentiateElement(g, q); |
| 595 | 595 | pass = pass && IsIdentity(gq); |
| 596 | 596 | } |
| 597 | 597 | return pass; |
| … |
… |
void DL_PublicKey_EC<EC>::BERDecodePublicKey(BufferedTransformation &bt, bool pa |
| 629 | 629 | typename EC::Point P; |
| 630 | 630 | if (!this->GetGroupParameters().GetCurve().DecodePoint(P, bt, size)) |
| 631 | 631 | BERDecodeError(); |
| 632 | | SetPublicElement(P); |
| | 632 | this->SetPublicElement(P); |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | template <class EC> |
diff --git a/embeddedcryptopp/eccrypto.h b/embeddedcryptopp/eccrypto.h
index 8d95780..7ac8d90 100644
|
a
|
b
|
public: |
| 43 | 43 | void Initialize(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k = Integer::Zero()) |
| 44 | 44 | { |
| 45 | 45 | this->m_groupPrecomputation.SetCurve(ec); |
| 46 | | SetSubgroupGenerator(G); |
| | 46 | this->SetSubgroupGenerator(G); |
| 47 | 47 | m_n = n; |
| 48 | 48 | m_k = k; |
| 49 | 49 | } |
| … |
… |
public: |
| 145 | 145 | typedef typename EC::Point Element; |
| 146 | 146 | |
| 147 | 147 | void Initialize(const DL_GroupParameters_EC<EC> ¶ms, const Element &Q) |
| 148 | | {this->AccessGroupParameters() = params; SetPublicElement(Q);} |
| | 148 | {this->AccessGroupParameters() = params; this->SetPublicElement(Q);} |
| 149 | 149 | void Initialize(const EC &ec, const Element &G, const Integer &n, const Element &Q) |
| 150 | | {this->AccessGroupParameters().Initialize(ec, G, n); SetPublicElement(Q);} |
| | 150 | {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPublicElement(Q);} |
| 151 | 151 | |
| 152 | 152 | // X509PublicKey |
| 153 | 153 | void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size); |
| … |
… |
public: |
| 166 | 166 | void Initialize(const EC &ec, const Element &G, const Integer &n, const Integer &x) |
| 167 | 167 | {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPrivateExponent(x);} |
| 168 | 168 | void Initialize(RandomNumberGenerator &rng, const DL_GroupParameters_EC<EC> ¶ms) |
| 169 | | {GenerateRandom(rng, params);} |
| | 169 | {this->GenerateRandom(rng, params);} |
| 170 | 170 | void Initialize(RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n) |
| 171 | | {GenerateRandom(rng, DL_GroupParameters_EC<EC>(ec, G, n));} |
| | 171 | {this->GenerateRandom(rng, DL_GroupParameters_EC<EC>(ec, G, n));} |
| 172 | 172 | |
| 173 | 173 | // PKCS8PrivateKey |
| 174 | 174 | void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size); |
diff --git a/embeddedcryptopp/secblock.h b/embeddedcryptopp/secblock.h
index d66470e..fb55014 100644
|
a
|
b
|
public: |
| 94 | 94 | |
| 95 | 95 | pointer allocate(size_type n, const void * = NULL) |
| 96 | 96 | { |
| 97 | | CheckSize(n); |
| | 97 | this->CheckSize(n); |
| 98 | 98 | if (n == 0) |
| 99 | 99 | return NULL; |
| 100 | 100 | |