Crypto++ 8.9
Free C++ class library of cryptographic schemes
xtrcrypt.h
Go to the documentation of this file.
1#ifndef CRYPTOPP_XTRCRYPT_H
2#define CRYPTOPP_XTRCRYPT_H
3
4/// \file
5/// \brief XTR public key system
6/// \sa "The XTR public key system" by Arjen K. Lenstra and Eric R. Verheul
7
8#include "cryptlib.h"
9#include "xtr.h"
10#include "integer.h"
11
12NAMESPACE_BEGIN(CryptoPP)
13
14/// \brief XTR-DH with key validation
16{
17 typedef XTR_DH ThisClass;
18
19public:
20 XTR_DH(const Integer &p, const Integer &q, const GFP2Element &g);
21 XTR_DH(RandomNumberGenerator &rng, unsigned int pbits, unsigned int qbits);
22 XTR_DH(BufferedTransformation &domainParams);
23
24 void DEREncode(BufferedTransformation &domainParams) const;
25
26 bool Validate(RandomNumberGenerator &rng, unsigned int level) const;
27 bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
28 void AssignFrom(const NameValuePairs &source);
30 unsigned int AgreedValueLength() const {return 2*m_p.ByteCount();}
31 unsigned int PrivateKeyLength() const {return m_q.ByteCount();}
32 unsigned int PublicKeyLength() const {return 2*m_p.ByteCount();}
33
34 void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const;
35 void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const;
36 bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const;
37
38 const Integer &GetModulus() const {return m_p;}
39 const Integer &GetSubgroupOrder() const {return m_q;}
40 const GFP2Element &GetSubgroupGenerator() const {return m_g;}
41
42 void SetModulus(const Integer &p) {m_p = p;}
43 void SetSubgroupOrder(const Integer &q) {m_q = q;}
44 void SetSubgroupGenerator(const GFP2Element &g) {m_g = g;}
45
46private:
47 unsigned int ExponentBitLength() const;
48
49 Integer m_p, m_q;
50 GFP2Element m_g;
51};
52
53NAMESPACE_END
54
55#endif
Interface for buffered transformations.
Definition cryptlib.h:1657
Interface for crypto parameters.
Definition cryptlib.h:2551
an element of GF(p^2)
Definition xtr.h:17
Multiple precision integer with arithmetic operations.
Definition integer.h:50
Interface for retrieving values given their names.
Definition cryptlib.h:327
Interface for random number generators.
Definition cryptlib.h:1440
Interface for domains of simple key agreement protocols.
Definition cryptlib.h:3018
XTR-DH with key validation.
Definition xtrcrypt.h:16
CryptoParameters & AccessCryptoParameters()
Retrieves a reference to Crypto Parameters.
Definition xtrcrypt.h:29
unsigned int AgreedValueLength() const
Provides the size of the agreed value.
Definition xtrcrypt.h:30
unsigned int PublicKeyLength() const
Provides the size of the public key.
Definition xtrcrypt.h:32
unsigned int PrivateKeyLength() const
Provides the size of the private key.
Definition xtrcrypt.h:31
Abstract base classes that provide a uniform interface to this library.
Multiple precision integer with arithmetic operations.
Crypto++ library namespace.
The XTR public key system.