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 {
23 public:
24  UT_ECCPrivateKey(const unsigned int *key, int nwords, const UT_ECurve *curve=0);
25  UT_ECCPrivateKey(const UT_VeryLong &lval, const UT_ECurve *curve=0);
26 
27  //
28  // Generate a random number given a seed
29  //
30  static void genRandom(UT_VeryLong &rnd,
31  const unsigned seed[], unsigned seedlen,
32  const UT_ECurve *curve=0);
33 
34  //
35  // Generate a random number given a bunch of random data.
36  // The random data must be larger than that needed for this purpose,
37  // false is returned if it fails.
38  static bool genRandomRaw(UT_VeryLong &rnd,
39  const unsigned seed[], unsigned seedlen,
40  const UT_ECurve *curve=0);
41 
42  //
43  // Given a random number (within the field modulus) and a message
44  // encode the message into 'e'. If the encoding failed, then please choose
45  // a different random number.
46  //
47  // WARNING: The message must be fewer than 160 bits (or so).
48  //
49  void genPubXY(UT_VeryLong &codea,
50  const UT_VeryLong &rnd) const ;
51  int encode(UT_VeryLong &codea, UT_VeryLong &codeb,
52  const UT_VeryLong &rnd,
53  const UT_VeryLong &message) const;
54  int encode(UT_VeryLong &codeb,
55  const unsigned seed[], unsigned seedlen,
56  const UT_VeryLong &message) const;
59 };
60 
62 {
63 public:
64  UT_ECCPublicKey(const UT_ECCPrivateKey &pkey);
65  UT_ECCPublicKey(const unsigned int *x, int nxwords,
66  const unsigned int *y, int nywords,
67  const UT_ECurve *curve = 0);
68  UT_ECCPublicKey(const UT_VeryLong &x, const UT_VeryLong &y,
69  const UT_ECurve *curve = 0);
70 
71  static void printCode(UT_WorkBuffer &buf, const UT_VeryLong &codea,
72  const UT_VeryLong &codeb);
73  static int scanCode(const char *buffer, UT_VeryLong &codea,
74  UT_VeryLong &codeb);
75 
76  int decode(const UT_VeryLong &message,
77  const UT_VeryLong &codea,
78  const UT_VeryLong &codeb) const;
79 
82 };
83 
84 #endif
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
#define UT_API
Definition: UT_API.h:14
UT_VeryLong myKey
Definition: UT_ECC.h:57
GLint y
Definition: glcorearb.h:103
GLuint buffer
Definition: glcorearb.h:660
const UT_ECurve * myCurve
Definition: UT_ECC.h:58
GLint GLenum GLint x
Definition: glcorearb.h:409
const UT_ECurve * myCurve
Definition: UT_ECC.h:81
UT_PolyField myY
Definition: UT_ECC.h:80