7 #if CRYPTOPP_MSC_VERSION
8 # pragma warning(disable: 4189 4589)
11 #ifndef CRYPTOPP_IMPORTS
23 #if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
24 void TestInstantiations_gfpcrypt()
28 DSA::Signer test5(
NullRNG(), 100);
29 DSA::Signer test2(test5);
48 int modulusSize = 2048, defaultSubgroupOrderSize;
54 defaultSubgroupOrderSize = 160;
57 defaultSubgroupOrderSize = 224;
60 defaultSubgroupOrderSize = 256;
75 const int pSize = GetModulus().
BitCount(), qSize = GetSubgroupOrder().
BitCount();
76 pass = pass && ((pSize==1024 && qSize==160) || (pSize==2048 && qSize==224) || (pSize==2048 && qSize==256) || (pSize==3072 && qSize==256));
83 const byte *recoverableMessage,
size_t recoverableMessageLength,
85 byte *representative,
size_t representativeBitLength)
const
87 CRYPTOPP_UNUSED(rng), CRYPTOPP_UNUSED(recoverableMessage), CRYPTOPP_UNUSED(recoverableMessageLength);
88 CRYPTOPP_UNUSED(messageEmpty), CRYPTOPP_UNUSED(hashIdentifier);
92 const size_t representativeByteLength =
BitsToBytes(representativeBitLength);
96 memset(representative, 0, paddingLength);
99 if (digestSize*8 > representativeBitLength)
101 Integer h(representative, representativeByteLength);
102 h >>= representativeByteLength*8 - representativeBitLength;
103 h.Encode(representative, representativeByteLength);
108 const byte *recoverableMessage,
size_t recoverableMessageLength,
110 byte *representative,
size_t representativeBitLength)
const
112 CRYPTOPP_UNUSED(rng);CRYPTOPP_UNUSED(recoverableMessage); CRYPTOPP_UNUSED(recoverableMessageLength);
113 CRYPTOPP_UNUSED(hash); CRYPTOPP_UNUSED(hashIdentifier); CRYPTOPP_UNUSED(messageEmpty);
114 CRYPTOPP_UNUSED(representative); CRYPTOPP_UNUSED(representativeBitLength);
118 const size_t representativeByteLength =
BitsToBytes(representativeBitLength);
120 const size_t paddingLength =
SaturatingSubtract(representativeByteLength, digestSize);
122 memset(representative, 0, paddingLength);
123 hash.
TruncatedFinal(representative+paddingLength,
STDMIN(representativeByteLength, digestSize));
125 if (digestSize*8 >= representativeBitLength)
127 Integer h(representative, representativeByteLength);
128 h >>= representativeByteLength*8 - representativeBitLength + 1;
129 h.Encode(representative, representativeByteLength);
135 const Integer &p = GetModulus(), &q = GetSubgroupOrder();
159 const Integer &p = GetModulus(), &q = GetSubgroupOrder();
162 pass = pass && GetFieldType() == 1 ? g.IsPositive() : g.NotNegative();
178 if (GetFieldType() == 2)
180 pass = pass &&
Jacobi(g*g-4, p)==-1;
186 bool fullValidate = (GetFieldType() == 2 && level >= 3) || !FastSubgroupCheckAvailable();
188 if (fullValidate && pass)
194 else if (GetFieldType() == 1)
196 pass = pass &&
Jacobi(g, p) == 1;
214 int modulusSize, subgroupOrderSize;
219 if (!alg.
GetIntValue(
"SubgroupOrderSize", subgroupOrderSize))
220 subgroupOrderSize = GetDefaultSubgroupOrderSize(modulusSize);
223 pg.
Generate(GetFieldType() == 1 ? 1 : -1, rng, modulusSize, subgroupOrderSize);
234 CRYPTOPP_UNUSED(reversible);
235 element.Encode(encoded, GetModulus().ByteCount());
240 CRYPTOPP_UNUSED(reversible);
246 CRYPTOPP_UNUSED(checkForGroupMembership);
247 Integer g(encoded, GetModulus().ByteCount());
259 if (parameters.EndReached())
262 q = ComputeGroupOrder(p) / 2;
265 g.BERDecode(parameters);
266 parameters.MessageEnd();
268 SetModulusAndSubgroupGenerator(p, g);
278 parameters.MessageEnd();
283 return GetValueHelper<DL_GroupParameters<Element> >(
this, name, valueType, pValue)
284 CRYPTOPP_GET_FUNCTION_ENTRY(Modulus);
289 AssignFromHelper(
this, source)
290 CRYPTOPP_SET_FUNCTION_ENTRY2(Modulus, SubgroupGenerator)
291 CRYPTOPP_SET_FUNCTION_ENTRY(SubgroupOrder)
295 OID DL_GroupParameters_IntegerBased::GetAlgorithmID()
const
297 return ASN1::id_dsa();
300 void DL_GroupParameters_GFP::SimultaneousExponentiate(Element *results,
const Element &base,
const Integer *exponents,
unsigned int exponentsCount)
const
303 ma.SimultaneousExponentiate(results, base, exponents, exponentsCount);
306 DL_GroupParameters_GFP::Element DL_GroupParameters_GFP::MultiplyElements(
const Element &a,
const Element &b)
const
308 return a_times_b_mod_c(a, b, GetModulus());
311 DL_GroupParameters_GFP::Element DL_GroupParameters_GFP::CascadeExponentiate(
const Element &element1,
const Integer &exponent1,
const Element &element2,
const Integer &exponent2)
const
314 return ma.CascadeExponentiate(element1, exponent1, element2, exponent2);
317 Integer DL_GroupParameters_IntegerBased::GetMaxExponent()
const
322 unsigned int DL_GroupParameters_IntegerBased::GetDefaultSubgroupOrderSize(
unsigned int modulusSize)
const