HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ECC.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_ECC.h ( Elliptic Curve Cryptography UT Library, C++)
7  *
8  * COMMENTS: Implementation of the NIST-163 ECC.
9  */
10 
11 #ifndef __UT_ECC__
12 #define __UT_ECC__
13 
14 #include "UT_API.h"
15 #include "UT_VeryLong.h"
16 #include "UT_PolyField.h"
17 
18 class UT_ECurve;
19 class UT_WorkBuffer;
20 
22 public:
23  UT_ECCPrivateKey(const unsigned int *key, int nwords, const UT_ECurve *curve=0);
24  UT_ECCPrivateKey(const UT_VeryLong &lval, const UT_ECurve *curve=0);
25 
26  //
27  // Generate a random number given a seed
28  //
29  static void genRandom(UT_VeryLong &rnd,
30  const unsigned seed[], unsigned seedlen,
31  const UT_ECurve *curve=0);
32 
33  //
34  // Generate a random number given a bunch of random data.
35  // The random data must be larger than that needed for this purpose,
36  // false is returned if it fails.
37  static bool genRandomRaw(UT_VeryLong &rnd,
38  const unsigned seed[], unsigned seedlen,
39  const UT_ECurve *curve=0);
40 
41  //
42  // Given a random number (within the field modulus) and a message
43  // encode the message into 'e'. If the encoding failed, then please choose
44  // a different random number.
45  //
46  // WARNING: The message must be fewer than 160 bits (or so).
47  //
48  void genPubXY(UT_VeryLong &codea,
49  const UT_VeryLong &rnd) const ;
50  int encode(UT_VeryLong &codea, UT_VeryLong &codeb,
51  const UT_VeryLong &rnd,
52  const UT_VeryLong &message) const;
53  int encode(UT_VeryLong &codeb,
54  const unsigned seed[], unsigned seedlen,
55  const UT_VeryLong &message) const;
58 };
59 
61 public:
62  UT_ECCPublicKey(const UT_ECCPrivateKey &pkey);
63  UT_ECCPublicKey(const unsigned int *x, int nxwords,
64  const unsigned int *y, int nywords,
65  const UT_ECurve *curve = 0);
66  UT_ECCPublicKey(const UT_VeryLong &x, const UT_VeryLong &y,
67  const UT_ECurve *curve = 0);
68 
69  static void printCode(UT_WorkBuffer &buf, const UT_VeryLong &codea,
70  const UT_VeryLong &codeb);
71  static int scanCode(const char *buffer, UT_VeryLong &codea,
72  UT_VeryLong &codeb);
73 
74  int decode(const UT_VeryLong &message,
75  const UT_VeryLong &codea,
76  const UT_VeryLong &codeb) const;
77 
80 };
81 
82 #endif
#define UT_API
Definition: UT_API.h:13
UT_VeryLong myKey
Definition: UT_ECC.h:56
GLint y
Definition: glcorearb.h:102
GLuint buffer
Definition: glcorearb.h:659
const UT_ECurve * myCurve
Definition: UT_ECC.h:57
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2542
const UT_ECurve * myCurve
Definition: UT_ECC.h:79
GLint GLenum GLint x
Definition: glcorearb.h:408
UT_PolyField myY
Definition: UT_ECC.h:78