<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Crypto++: eccrypto.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>eccrypto.h</h1><a href="eccrypto_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_ECCRYPTO_H</span> <a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_ECCRYPTO_H</span> <a name="l00003"></a>00003 <span class="preprocessor"></span><span class="comment"></span> <a name="l00004"></a>00004 <span class="comment">/*! \file</span> <a name="l00005"></a>00005 <span class="comment">*/</span> <a name="l00006"></a>00006 <a name="l00007"></a>00007 <span class="preprocessor">#include "<a class="code" href="pubkey_8h.html" title="This file contains helper classes/functions for implementing public key algorithms...">pubkey.h</a>"</span> <a name="l00008"></a>00008 <span class="preprocessor">#include "<a class="code" href="integer_8h.html">integer.h</a>"</span> <a name="l00009"></a>00009 <span class="preprocessor">#include "asn.h"</span> <a name="l00010"></a>00010 <span class="preprocessor">#include "hmac.h"</span> <a name="l00011"></a>00011 <span class="preprocessor">#include "sha.h"</span> <a name="l00012"></a>00012 <span class="preprocessor">#include "<a class="code" href="gfpcrypt_8h.html" title="Implementation of schemes based on DL over GF(p).">gfpcrypt.h</a>"</span> <a name="l00013"></a>00013 <span class="preprocessor">#include "<a class="code" href="dh_8h.html">dh.h</a>"</span> <a name="l00014"></a>00014 <span class="preprocessor">#include "<a class="code" href="mqv_8h.html">mqv.h</a>"</span> <a name="l00015"></a>00015 <span class="preprocessor">#include "ecp.h"</span> <a name="l00016"></a>00016 <span class="preprocessor">#include "ec2n.h"</span> <a name="l00017"></a>00017 <a name="l00018"></a>00018 NAMESPACE_BEGIN(CryptoPP) <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="comment">//! Elliptic Curve Parameters</span> <a name="l00021"></a>00021 <span class="comment"></span><span class="comment">/*! This class corresponds to the ASN.1 sequence of the same name</span> <a name="l00022"></a>00022 <span class="comment"> in ANSI X9.62 (also SEC 1).</span> <a name="l00023"></a>00023 <span class="comment">*/</span> <a name="l00024"></a>00024 template <class EC> <a name="l00025"></a><a class="code" href="class_d_l___group_parameters___e_c.html">00025</a> class <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a> : public <a class="code" href="class_d_l___group_parameters_impl.html" title="_">DL_GroupParametersImpl</a><EcPrecomputation<EC> > <a name="l00026"></a>00026 { <a name="l00027"></a>00027 <span class="keyword">typedef</span> <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC<EC></a> <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">ThisClass</a>; <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="keyword">public</span>: <a name="l00030"></a>00030 <span class="keyword">typedef</span> EC EllipticCurve; <a name="l00031"></a>00031 <span class="keyword">typedef</span> <span class="keyword">typename</span> EllipticCurve::Point Point; <a name="l00032"></a>00032 <span class="keyword">typedef</span> Point Element; <a name="l00033"></a>00033 <span class="keyword">typedef</span> <a class="code" href="struct_enum_to_type.html">IncompatibleCofactorMultiplication</a> <a class="code" href="struct_enum_to_type.html">DefaultCofactorOption</a>; <a name="l00034"></a>00034 <a name="l00035"></a>00035 <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a>() : m_compress(<span class="keyword">false</span>), m_encodeAsOID(<span class="keyword">false</span>) {} <a name="l00036"></a>00036 <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a>(<span class="keyword">const</span> <a class="code" href="class_o_i_d.html" title="Object Identifier.">OID</a> &oid) <a name="l00037"></a>00037 : m_compress(<span class="keyword">false</span>), m_encodeAsOID(<span class="keyword">false</span>) {Initialize(oid);} <a name="l00038"></a>00038 <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a>(<span class="keyword">const</span> EllipticCurve &ec, <span class="keyword">const</span> Point &G, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &n, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &k = <a class="code" href="class_integer.html#a19b7e6d48b1b57bd4846160ea2928175" title="avoid calling constructors for these frequently used integers">Integer::Zero</a>()) <a name="l00039"></a>00039 : m_compress(<span class="keyword">false</span>), m_encodeAsOID(<span class="keyword">false</span>) {Initialize(ec, G, n, k);} <a name="l00040"></a>00040 <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt) <a name="l00041"></a>00041 : m_compress(<span class="keyword">false</span>), m_encodeAsOID(<span class="keyword">false</span>) {BERDecode(bt);} <a name="l00042"></a>00042 <a name="l00043"></a>00043 <span class="keywordtype">void</span> Initialize(<span class="keyword">const</span> EllipticCurve &ec, <span class="keyword">const</span> Point &G, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &n, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &k = <a class="code" href="class_integer.html#a19b7e6d48b1b57bd4846160ea2928175" title="avoid calling constructors for these frequently used integers">Integer::Zero</a>()) <a name="l00044"></a>00044 { <a name="l00045"></a>00045 this->m_groupPrecomputation.SetCurve(ec); <a name="l00046"></a>00046 SetSubgroupGenerator(G); <a name="l00047"></a>00047 m_n = n; <a name="l00048"></a>00048 m_k = k; <a name="l00049"></a>00049 } <a name="l00050"></a>00050 <span class="keywordtype">void</span> Initialize(<span class="keyword">const</span> <a class="code" href="class_o_i_d.html" title="Object Identifier.">OID</a> &oid); <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="comment">// NameValuePairs</span> <a name="l00053"></a>00053 <span class="keywordtype">bool</span> GetVoidValue(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, <span class="keyword">const</span> std::type_info &valueType, <span class="keywordtype">void</span> *pValue) <span class="keyword">const</span>; <a name="l00054"></a>00054 <span class="keywordtype">void</span> AssignFrom(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &source); <a name="l00055"></a>00055 <a name="l00056"></a>00056 <span class="comment">// GeneratibleCryptoMaterial interface</span><span class="comment"></span> <a name="l00057"></a>00057 <span class="comment"> //! this implementation doesn't actually generate a curve, it just initializes the parameters with existing values</span> <a name="l00058"></a>00058 <span class="comment"></span><span class="comment"> /*! parameters: (Curve, SubgroupGenerator, SubgroupOrder, Cofactor (optional)), or (GroupOID) */</span> <a name="l00059"></a>00059 <span class="keywordtype">void</span> GenerateRandom(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &rng, <span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &alg); <a name="l00060"></a>00060 <a name="l00061"></a>00061 <span class="comment">// DL_GroupParameters</span> <a name="l00062"></a>00062 <span class="keyword">const</span> <a class="code" href="class_d_l___fixed_base_precomputation.html">DL_FixedBasePrecomputation<Element></a> & GetBasePrecomputation()<span class="keyword"> const </span>{<span class="keywordflow">return</span> this->m_gpc;} <a name="l00063"></a>00063 <a class="code" href="class_d_l___fixed_base_precomputation.html">DL_FixedBasePrecomputation<Element></a> & AccessBasePrecomputation() {<span class="keywordflow">return</span> this->m_gpc;} <a name="l00064"></a>00064 <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> & GetSubgroupOrder()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_n;} <a name="l00065"></a>00065 <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> GetCofactor() <span class="keyword">const</span>; <a name="l00066"></a>00066 <span class="keywordtype">bool</span> ValidateGroup(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &rng, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> level) <span class="keyword">const</span>; <a name="l00067"></a>00067 <span class="keywordtype">bool</span> ValidateElement(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> level, <span class="keyword">const</span> Element &element, <span class="keyword">const</span> <a class="code" href="class_d_l___fixed_base_precomputation.html">DL_FixedBasePrecomputation<Element></a> *precomp) <span class="keyword">const</span>; <a name="l00068"></a>00068 <span class="keywordtype">bool</span> FastSubgroupCheckAvailable()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">false</span>;} <a name="l00069"></a>00069 <span class="keywordtype">void</span> EncodeElement(<span class="keywordtype">bool</span> reversible, <span class="keyword">const</span> Element &element, byte *encoded)<span class="keyword"> const</span> <a name="l00070"></a>00070 <span class="keyword"> </span>{ <a name="l00071"></a>00071 <span class="keywordflow">if</span> (reversible) <a name="l00072"></a>00072 GetCurve().EncodePoint(encoded, element, m_compress); <a name="l00073"></a>00073 <span class="keywordflow">else</span> <a name="l00074"></a>00074 element.x.Encode(encoded, GetEncodedElementSize(<span class="keyword">false</span>)); <a name="l00075"></a>00075 } <a name="l00076"></a>00076 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetEncodedElementSize(<span class="keywordtype">bool</span> reversible)<span class="keyword"> const</span> <a name="l00077"></a>00077 <span class="keyword"> </span>{ <a name="l00078"></a>00078 <span class="keywordflow">if</span> (reversible) <a name="l00079"></a>00079 <span class="keywordflow">return</span> GetCurve().EncodedPointSize(m_compress); <a name="l00080"></a>00080 <span class="keywordflow">else</span> <a name="l00081"></a>00081 <span class="keywordflow">return</span> GetCurve().GetField().MaxElementByteLength(); <a name="l00082"></a>00082 } <a name="l00083"></a>00083 Element DecodeElement(<span class="keyword">const</span> byte *encoded, <span class="keywordtype">bool</span> checkForGroupMembership)<span class="keyword"> const</span> <a name="l00084"></a>00084 <span class="keyword"> </span>{ <a name="l00085"></a>00085 Point result; <a name="l00086"></a>00086 <span class="keywordflow">if</span> (!GetCurve().DecodePoint(result, encoded, GetEncodedElementSize(<span class="keyword">true</span>))) <a name="l00087"></a>00087 <span class="keywordflow">throw</span> <a class="code" href="class_d_l___bad_element.html" title="to be thrown by DecodeElement and AgreeWithStaticPrivateKey">DL_BadElement</a>(); <a name="l00088"></a>00088 <span class="keywordflow">if</span> (checkForGroupMembership && !ValidateElement(1, result, NULL)) <a name="l00089"></a>00089 <span class="keywordflow">throw</span> <a class="code" href="class_d_l___bad_element.html" title="to be thrown by DecodeElement and AgreeWithStaticPrivateKey">DL_BadElement</a>(); <a name="l00090"></a>00090 <span class="keywordflow">return</span> result; <a name="l00091"></a>00091 } <a name="l00092"></a>00092 <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> ConvertElementToInteger(<span class="keyword">const</span> Element &element) <span class="keyword">const</span>; <a name="l00093"></a>00093 <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> GetMaxExponent()<span class="keyword"> const </span>{<span class="keywordflow">return</span> GetSubgroupOrder()-1;} <a name="l00094"></a>00094 <span class="keywordtype">bool</span> IsIdentity(<span class="keyword">const</span> Element &element)<span class="keyword"> const </span>{<span class="keywordflow">return</span> element.identity;} <a name="l00095"></a>00095 <span class="keywordtype">void</span> SimultaneousExponentiate(Element *results, <span class="keyword">const</span> Element &base, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> *exponents, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> exponentsCount) <span class="keyword">const</span>; <a name="l00096"></a>00096 <span class="keyword">static</span> std::string CRYPTOPP_API StaticAlgorithmNamePrefix() {<span class="keywordflow">return</span> <span class="stringliteral">"EC"</span>;} <a name="l00097"></a>00097 <a name="l00098"></a>00098 <span class="comment">// ASN1Key</span> <a name="l00099"></a>00099 <a class="code" href="class_o_i_d.html" title="Object Identifier.">OID</a> GetAlgorithmID() <span class="keyword">const</span>; <a name="l00100"></a>00100 <a name="l00101"></a>00101 <span class="comment">// used by MQV</span> <a name="l00102"></a>00102 Element MultiplyElements(<span class="keyword">const</span> Element &a, <span class="keyword">const</span> Element &b) <span class="keyword">const</span>; <a name="l00103"></a>00103 Element CascadeExponentiate(<span class="keyword">const</span> Element &element1, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &exponent1, <span class="keyword">const</span> Element &element2, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &exponent2) <span class="keyword">const</span>; <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="comment">// non-inherited</span> <a name="l00106"></a>00106 <a name="l00107"></a>00107 <span class="comment">// enumerate OIDs for recommended parameters, use OID() to get first one</span> <a name="l00108"></a>00108 <span class="keyword">static</span> <a class="code" href="class_o_i_d.html" title="Object Identifier.">OID</a> CRYPTOPP_API GetNextRecommendedParametersOID(<span class="keyword">const</span> <a class="code" href="class_o_i_d.html" title="Object Identifier.">OID</a> &oid); <a name="l00109"></a>00109 <a name="l00110"></a>00110 <span class="keywordtype">void</span> BERDecode(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt); <a name="l00111"></a>00111 <span class="keywordtype">void</span> DEREncode(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt) <span class="keyword">const</span>; <a name="l00112"></a>00112 <a name="l00113"></a>00113 <span class="keywordtype">void</span> SetPointCompression(<span class="keywordtype">bool</span> compress) {m_compress = compress;} <a name="l00114"></a>00114 <span class="keywordtype">bool</span> GetPointCompression()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_compress;} <a name="l00115"></a>00115 <a name="l00116"></a>00116 <span class="keywordtype">void</span> SetEncodeAsOID(<span class="keywordtype">bool</span> encodeAsOID) {m_encodeAsOID = encodeAsOID;} <a name="l00117"></a>00117 <span class="keywordtype">bool</span> GetEncodeAsOID()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_encodeAsOID;} <a name="l00118"></a>00118 <a name="l00119"></a>00119 <span class="keyword">const</span> EllipticCurve& GetCurve()<span class="keyword"> const </span>{<span class="keywordflow">return</span> this->m_groupPrecomputation.GetCurve();} <a name="l00120"></a>00120 <a name="l00121"></a>00121 <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> ThisClass &rhs)<span class="keyword"> const</span> <a name="l00122"></a>00122 <span class="keyword"> </span>{<span class="keywordflow">return</span> this->m_groupPrecomputation.GetCurve() == rhs.m_groupPrecomputation.GetCurve() && this->m_gpc.GetBase(this->m_groupPrecomputation) == rhs.m_gpc.GetBase(rhs.m_groupPrecomputation);} <a name="l00123"></a>00123 <a name="l00124"></a>00124 <span class="preprocessor">#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY</span> <a name="l00125"></a>00125 <span class="preprocessor"></span> <span class="keyword">const</span> Point& GetBasePoint()<span class="keyword"> const </span>{<span class="keywordflow">return</span> GetSubgroupGenerator();} <a name="l00126"></a>00126 <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& GetBasePointOrder()<span class="keyword"> const </span>{<span class="keywordflow">return</span> GetSubgroupOrder();} <a name="l00127"></a>00127 <span class="keywordtype">void</span> LoadRecommendedParameters(<span class="keyword">const</span> <a class="code" href="class_o_i_d.html" title="Object Identifier.">OID</a> &oid) {Initialize(oid);} <a name="l00128"></a>00128 <span class="preprocessor">#endif</span> <a name="l00129"></a>00129 <span class="preprocessor"></span> <a name="l00130"></a>00130 <span class="keyword">protected</span>: <a name="l00131"></a>00131 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> FieldElementLength()<span class="keyword"> const </span>{<span class="keywordflow">return</span> GetCurve().GetField().MaxElementByteLength();} <a name="l00132"></a>00132 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ExponentLength()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_n.ByteCount();} <a name="l00133"></a>00133 <a name="l00134"></a>00134 <a class="code" href="class_o_i_d.html" title="Object Identifier.">OID</a> m_oid; <span class="comment">// set if parameters loaded from a recommended curve</span> <a name="l00135"></a>00135 <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> m_n; <span class="comment">// order of base point</span> <a name="l00136"></a>00136 <span class="keywordtype">bool</span> m_compress, m_encodeAsOID; <a name="l00137"></a>00137 <span class="keyword">mutable</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> m_k; <span class="comment">// cofactor</span> <a name="l00138"></a>00138 }; <a name="l00139"></a>00139 <span class="comment"></span> <a name="l00140"></a>00140 <span class="comment">//! EC public key</span> <a name="l00141"></a>00141 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> EC> <a name="l00142"></a><a class="code" href="class_d_l___public_key___e_c.html">00142</a> <span class="keyword">class </span><a class="code" href="class_d_l___public_key___e_c.html" title="EC public key.">DL_PublicKey_EC</a> : <span class="keyword">public</span> <a class="code" href="class_d_l___public_key_impl.html" title="_">DL_PublicKeyImpl</a><DL_GroupParameters_EC<EC> > <a name="l00143"></a>00143 { <a name="l00144"></a>00144 <span class="keyword">public</span>: <a name="l00145"></a>00145 <span class="keyword">typedef</span> <span class="keyword">typename</span> EC::Point Element; <a name="l00146"></a>00146 <a name="l00147"></a>00147 <span class="keywordtype">void</span> Initialize(<span class="keyword">const</span> <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC<EC></a> &params, <span class="keyword">const</span> Element &Q) <a name="l00148"></a>00148 {this->AccessGroupParameters() = params; SetPublicElement(Q);} <a name="l00149"></a>00149 <span class="keywordtype">void</span> Initialize(<span class="keyword">const</span> EC &ec, <span class="keyword">const</span> Element &G, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &n, <span class="keyword">const</span> Element &Q) <a name="l00150"></a>00150 {this->AccessGroupParameters().Initialize(ec, G, n); SetPublicElement(Q);} <a name="l00151"></a>00151 <a name="l00152"></a>00152 <span class="comment">// X509PublicKey</span> <a name="l00153"></a>00153 <span class="keywordtype">void</span> <a class="code" href="class_d_l___public_key___e_c.html#ab436957725e2d94340f3de56b1260109" title="decode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header...">BERDecodePublicKey</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt, <span class="keywordtype">bool</span> parametersPresent, <span class="keywordtype">size_t</span> size); <a name="l00154"></a>00154 <span class="keywordtype">void</span> <a class="code" href="class_d_l___public_key___e_c.html#a8ab4bc2bb34c0572cbba3e5830bd64a7" title="encode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header...">DEREncodePublicKey</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt) <span class="keyword">const</span>; <a name="l00155"></a>00155 }; <a name="l00156"></a>00156 <span class="comment"></span> <a name="l00157"></a>00157 <span class="comment">//! EC private key</span> <a name="l00158"></a>00158 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> EC> <a name="l00159"></a><a class="code" href="class_d_l___private_key___e_c.html">00159</a> <span class="keyword">class </span><a class="code" href="class_d_l___private_key___e_c.html" title="EC private key.">DL_PrivateKey_EC</a> : <span class="keyword">public</span> <a class="code" href="class_d_l___private_key_impl.html" title="_">DL_PrivateKeyImpl</a><DL_GroupParameters_EC<EC> > <a name="l00160"></a>00160 { <a name="l00161"></a>00161 <span class="keyword">public</span>: <a name="l00162"></a>00162 <span class="keyword">typedef</span> <span class="keyword">typename</span> EC::Point Element; <a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="keywordtype">void</span> Initialize(<span class="keyword">const</span> <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC<EC></a> &params, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &x) <a name="l00165"></a>00165 {this->AccessGroupParameters() = params; this->SetPrivateExponent(x);} <a name="l00166"></a>00166 <span class="keywordtype">void</span> Initialize(<span class="keyword">const</span> EC &ec, <span class="keyword">const</span> Element &G, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &n, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &x) <a name="l00167"></a>00167 {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPrivateExponent(x);} <a name="l00168"></a>00168 <span class="keywordtype">void</span> Initialize(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &rng, <span class="keyword">const</span> <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC<EC></a> &params) <a name="l00169"></a>00169 {<a class="code" href="class_d_l___private_key_impl.html#ab80a3771a5ef623677775f7c5dddb1e0" title="generate a random key or crypto parameters">GenerateRandom</a>(rng, params);} <a name="l00170"></a>00170 <span class="keywordtype">void</span> Initialize(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &rng, <span class="keyword">const</span> EC &ec, <span class="keyword">const</span> Element &G, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &n) <a name="l00171"></a>00171 {<a class="code" href="class_d_l___private_key_impl.html#ab80a3771a5ef623677775f7c5dddb1e0" title="generate a random key or crypto parameters">GenerateRandom</a>(rng, <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC<EC></a>(ec, G, n));} <a name="l00172"></a>00172 <a name="l00173"></a>00173 <span class="comment">// PKCS8PrivateKey</span> <a name="l00174"></a>00174 <span class="keywordtype">void</span> <a class="code" href="class_d_l___private_key___e_c.html#a790483afe21298af518603dd50fff6cd" title="decode privateKey part of privateKeyInfo, without the OCTET STRING header">BERDecodePrivateKey</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt, <span class="keywordtype">bool</span> parametersPresent, <span class="keywordtype">size_t</span> size); <a name="l00175"></a>00175 <span class="keywordtype">void</span> <a class="code" href="class_d_l___private_key___e_c.html#afc281492defbf652c0cdb1af4a9f3df7" title="encode privateKey part of privateKeyInfo, without the OCTET STRING header">DEREncodePrivateKey</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt) <span class="keyword">const</span>; <a name="l00176"></a>00176 }; <a name="l00177"></a>00177 <span class="comment"></span> <a name="l00178"></a>00178 <span class="comment">//! Elliptic Curve Diffie-Hellman, AKA <a href="http://www.weidai.com/scan-mirror/ka.html#ECDH">ECDH</a></span> <a name="l00179"></a>00179 <span class="comment"></span>template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption> <a name="l00180"></a><a class="code" href="struct_e_c_d_h.html">00180</a> <span class="keyword">struct </span><a class="code" href="struct_e_c_d_h.html" title="Elliptic Curve Diffie-Hellman, AKA ECDH.">ECDH</a> <a name="l00181"></a>00181 { <a name="l00182"></a>00182 <span class="keyword">typedef</span> <a class="code" href="class_d_h___domain.html" title=",">DH_Domain<DL_GroupParameters_EC<EC></a>, COFACTOR_OPTION> <a class="code" href="class_d_h___domain.html" title=",">Domain</a>; <a name="l00183"></a>00183 }; <a name="l00184"></a>00184 <span class="comment"></span> <a name="l00185"></a>00185 <span class="comment">/// Elliptic Curve Menezes-Qu-Vanstone, AKA <a href="http://www.weidai.com/scan-mirror/ka.html#ECMQV">ECMQV</a></span> <a name="l00186"></a>00186 <span class="comment"></span>template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption> <a name="l00187"></a><a class="code" href="struct_e_c_m_q_v.html">00187</a> <span class="keyword">struct </span><a class="code" href="struct_e_c_m_q_v.html" title="Elliptic Curve Menezes-Qu-Vanstone, AKA ECMQV.">ECMQV</a> <a name="l00188"></a>00188 { <a name="l00189"></a>00189 <span class="keyword">typedef</span> <a class="code" href="class_m_q_v___domain.html" title="_">MQV_Domain<DL_GroupParameters_EC<EC></a>, COFACTOR_OPTION> <a class="code" href="class_m_q_v___domain.html" title="_">Domain</a>; <a name="l00190"></a>00190 }; <a name="l00191"></a>00191 <span class="comment"></span> <a name="l00192"></a>00192 <span class="comment">//! EC keys</span> <a name="l00193"></a>00193 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> EC> <a name="l00194"></a><a class="code" href="struct_d_l___keys___e_c.html">00194</a> <span class="keyword">struct </span><a class="code" href="struct_d_l___keys___e_c.html" title="EC keys.">DL_Keys_EC</a> <a name="l00195"></a>00195 { <a name="l00196"></a>00196 <span class="keyword">typedef</span> <a class="code" href="class_d_l___public_key___e_c.html" title="EC public key.">DL_PublicKey_EC<EC></a> <a class="code" href="class_d_l___public_key___e_c.html" title="EC public key.">PublicKey</a>; <a name="l00197"></a>00197 <span class="keyword">typedef</span> <a class="code" href="class_d_l___private_key___e_c.html" title="EC private key.">DL_PrivateKey_EC<EC></a> <a class="code" href="class_d_l___private_key___e_c.html" title="EC private key.">PrivateKey</a>; <a name="l00198"></a>00198 }; <a name="l00199"></a>00199 <a name="l00200"></a>00200 <span class="keyword">template</span> <<span class="keyword">class</span> EC, <span class="keyword">class</span> H = SHA> <a name="l00201"></a>00201 <span class="keyword">struct </span><a class="code" href="struct_e_c_d_s_a.html" title="ECDSA">ECDSA</a>; <a name="l00202"></a>00202 <span class="comment"></span> <a name="l00203"></a>00203 <span class="comment">//! ECDSA keys</span> <a name="l00204"></a>00204 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> EC> <a name="l00205"></a><a class="code" href="struct_d_l___keys___e_c_d_s_a.html">00205</a> <span class="keyword">struct </span><a class="code" href="struct_d_l___keys___e_c_d_s_a.html" title="ECDSA keys.">DL_Keys_ECDSA</a> <a name="l00206"></a>00206 { <a name="l00207"></a>00207 <span class="keyword">typedef</span> <a class="code" href="class_d_l___public_key___e_c.html" title="EC public key.">DL_PublicKey_EC<EC></a> <a class="code" href="class_d_l___public_key___e_c.html" title="EC public key.">PublicKey</a>; <a name="l00208"></a>00208 <span class="keyword">typedef</span> <a class="code" href="class_d_l___private_key___with_signature_pairwise_consistency_test.html" title="_">DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_EC<EC></a>, <a class="code" href="struct_e_c_d_s_a.html" title="ECDSA">ECDSA<EC></a> > <a class="code" href="class_d_l___private_key___with_signature_pairwise_consistency_test.html" title="_">PrivateKey</a>; <a name="l00209"></a>00209 }; <a name="l00210"></a>00210 <span class="comment"></span> <a name="l00211"></a>00211 <span class="comment">//! ECDSA algorithm</span> <a name="l00212"></a>00212 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> EC> <a name="l00213"></a><a class="code" href="class_d_l___algorithm___e_c_d_s_a.html">00213</a> <span class="keyword">class </span><a class="code" href="class_d_l___algorithm___e_c_d_s_a.html" title="ECDSA algorithm.">DL_Algorithm_ECDSA</a> : <span class="keyword">public</span> <a class="code" href="class_d_l___algorithm___g_d_s_a.html" title="GDSA algorithm.">DL_Algorithm_GDSA</a><typename EC::Point> <a name="l00214"></a>00214 { <a name="l00215"></a>00215 <span class="keyword">public</span>: <a name="l00216"></a>00216 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * CRYPTOPP_API StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"ECDSA"</span>;} <a name="l00217"></a>00217 }; <a name="l00218"></a>00218 <span class="comment"></span> <a name="l00219"></a>00219 <span class="comment">//! ECNR algorithm</span> <a name="l00220"></a>00220 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> EC> <a name="l00221"></a><a class="code" href="class_d_l___algorithm___e_c_n_r.html">00221</a> <span class="keyword">class </span><a class="code" href="class_d_l___algorithm___e_c_n_r.html" title="ECNR algorithm.">DL_Algorithm_ECNR</a> : <span class="keyword">public</span> <a class="code" href="class_d_l___algorithm___n_r.html" title="NR algorithm.">DL_Algorithm_NR</a><typename EC::Point> <a name="l00222"></a>00222 { <a name="l00223"></a>00223 <span class="keyword">public</span>: <a name="l00224"></a>00224 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * CRYPTOPP_API StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"ECNR"</span>;} <a name="l00225"></a>00225 }; <a name="l00226"></a>00226 <span class="comment"></span> <a name="l00227"></a>00227 <span class="comment">//! <a href="http://www.weidai.com/scan-mirror/sig.html#ECDSA">ECDSA</a></span> <a name="l00228"></a>00228 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> EC, <span class="keyword">class</span> H> <a name="l00229"></a><a class="code" href="struct_e_c_d_s_a.html">00229</a> <span class="keyword">struct </span><a class="code" href="struct_e_c_d_s_a.html" title="ECDSA">ECDSA</a> : <span class="keyword">public</span> <a class="code" href="class_d_l___s_s.html" title="Discrete Log Based Signature Scheme.">DL_SS</a><DL_Keys_ECDSA<EC>, DL_Algorithm_ECDSA<EC>, DL_SignatureMessageEncodingMethod_DSA, H> <a name="l00230"></a>00230 { <a name="l00231"></a>00231 }; <a name="l00232"></a>00232 <span class="comment"></span> <a name="l00233"></a>00233 <span class="comment">//! ECNR</span> <a name="l00234"></a>00234 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> EC, <span class="keyword">class</span> H = SHA> <a name="l00235"></a><a class="code" href="struct_e_c_n_r.html">00235</a> <span class="keyword">struct </span><a class="code" href="struct_e_c_n_r.html" title="ECNR.">ECNR</a> : <span class="keyword">public</span> <a class="code" href="class_d_l___s_s.html" title="Discrete Log Based Signature Scheme.">DL_SS</a><DL_Keys_EC<EC>, DL_Algorithm_ECNR<EC>, DL_SignatureMessageEncodingMethod_NR, H> <a name="l00236"></a>00236 { <a name="l00237"></a>00237 }; <a name="l00238"></a>00238 <span class="comment"></span> <a name="l00239"></a>00239 <span class="comment">//! Elliptic Curve Integrated Encryption Scheme, AKA <a href="http://www.weidai.com/scan-mirror/ca.html#ECIES">ECIES</a></span> <a name="l00240"></a>00240 <span class="comment"></span><span class="comment">/*! Default to (NoCofactorMultiplication and DHAES_MODE = false) for compatibilty with SEC1 and Crypto++ 4.2.</span> <a name="l00241"></a>00241 <span class="comment"> The combination of (IncompatibleCofactorMultiplication and DHAES_MODE = true) is recommended for best</span> <a name="l00242"></a>00242 <span class="comment"> efficiency and security. */</span> <a name="l00243"></a>00243 <span class="keyword">template</span> <<span class="keyword">class</span> EC, <span class="keyword">class</span> COFACTOR_OPTION = NoCofactorMultiplication, <span class="keywordtype">bool</span> DHAES_MODE = false> <a name="l00244"></a><a class="code" href="struct_e_c_i_e_s.html">00244</a> <span class="keyword">struct </span><a class="code" href="struct_e_c_i_e_s.html" title="Elliptic Curve Integrated Encryption Scheme, AKA ECIES.">ECIES</a> <a name="l00245"></a>00245 : <span class="keyword">public</span> <a class="code" href="class_d_l___e_s.html" title="Discrete Log Based Encryption Scheme.">DL_ES</a>< <a name="l00246"></a>00246 DL_Keys_EC<EC>, <a name="l00247"></a>00247 DL_KeyAgreementAlgorithm_DH<typename EC::Point, COFACTOR_OPTION>, <a name="l00248"></a>00248 DL_KeyDerivationAlgorithm_P1363<typename EC::Point, DHAES_MODE, P1363_KDF2<SHA1> >, <a name="l00249"></a>00249 DL_EncryptionAlgorithm_Xor<HMAC<SHA1>, DHAES_MODE>, <a name="l00250"></a>00250 ECIES<EC> > <a name="l00251"></a>00251 { <a name="l00252"></a>00252 <span class="keyword">static</span> std::string CRYPTOPP_API StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"ECIES"</span>;} <span class="comment">// TODO: fix this after name is standardized</span> <a name="l00253"></a>00253 }; <a name="l00254"></a>00254 <a name="l00255"></a>00255 NAMESPACE_END <a name="l00256"></a>00256 <a name="l00257"></a>00257 <span class="preprocessor">#ifdef CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES</span> <a name="l00258"></a>00258 <span class="preprocessor"></span><span class="preprocessor">#include "eccrypto.cpp"</span> <a name="l00259"></a>00259 <span class="preprocessor">#endif</span> <a name="l00260"></a>00260 <span class="preprocessor"></span> <a name="l00261"></a>00261 NAMESPACE_BEGIN(CryptoPP) <a name="l00262"></a>00262 <a name="l00263"></a>00263 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a><<a class="code" href="class_e_c_p.html" title="Elliptic Curve over GF(p), where p is prime.">ECP</a>>; <a name="l00264"></a>00264 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a><<a class="code" href="class_e_c2_n.html" title="Elliptic Curve over GF(2^n).">EC2N</a>>; <a name="l00265"></a>00265 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___public_key_impl.html" title="_">DL_PublicKeyImpl</a><<a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a><ECP> >; <a name="l00266"></a>00266 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___public_key_impl.html" title="_">DL_PublicKeyImpl</a><<a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a><EC2N> >; <a name="l00267"></a>00267 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___public_key___e_c.html" title="EC public key.">DL_PublicKey_EC</a><ECP>; <a name="l00268"></a>00268 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___public_key___e_c.html" title="EC public key.">DL_PublicKey_EC</a><EC2N>; <a name="l00269"></a>00269 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___private_key_impl.html" title="_">DL_PrivateKeyImpl</a><<a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a><ECP> >; <a name="l00270"></a>00270 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___private_key_impl.html" title="_">DL_PrivateKeyImpl</a><<a class="code" href="class_d_l___group_parameters___e_c.html" title="Elliptic Curve Parameters.">DL_GroupParameters_EC</a><EC2N> >; <a name="l00271"></a>00271 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___private_key___e_c.html" title="EC private key.">DL_PrivateKey_EC</a><ECP>; <a name="l00272"></a>00272 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___private_key___e_c.html" title="EC private key.">DL_PrivateKey_EC</a><EC2N>; <a name="l00273"></a>00273 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___algorithm___g_d_s_a.html" title="GDSA algorithm.">DL_Algorithm_GDSA</a><ECP::Point>; <a name="l00274"></a>00274 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___algorithm___g_d_s_a.html" title="GDSA algorithm.">DL_Algorithm_GDSA</a><EC2N::Point>; <a name="l00275"></a>00275 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___private_key___with_signature_pairwise_consistency_test.html" title="_">DL_PrivateKey_WithSignaturePairwiseConsistencyTest</a><<a class="code" href="class_d_l___private_key___e_c.html" title="EC private key.">DL_PrivateKey_EC</a><ECP>, <a class="code" href="struct_e_c_d_s_a.html" title="ECDSA">ECDSA</a><ECP> >; <a name="l00276"></a>00276 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_d_l___private_key___with_signature_pairwise_consistency_test.html" title="_">DL_PrivateKey_WithSignaturePairwiseConsistencyTest</a><<a class="code" href="class_d_l___private_key___e_c.html" title="EC private key.">DL_PrivateKey_EC</a><EC2N>, <a class="code" href="struct_e_c_d_s_a.html" title="ECDSA">ECDSA</a><EC2N> >; <a name="l00277"></a>00277 <a name="l00278"></a>00278 NAMESPACE_END <a name="l00279"></a>00279 <a name="l00280"></a>00280 <span class="preprocessor">#endif</span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated on 9 Dec 2009 for Crypto++ by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>