00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __UT_ECC__
00020 #define __UT_ECC__
00021
00022 #include "UT_API.h"
00023 #include "UT_VeryLong.h"
00024 #include "UT_PolyField.h"
00025
00026 class UT_ECurve;
00027 class UT_WorkBuffer;
00028
00029 class UT_API UT_ECCPrivateKey {
00030 public:
00031 UT_ECCPrivateKey(const unsigned int *key, int nwords, const UT_ECurve *curve=0);
00032 UT_ECCPrivateKey(const UT_VeryLong &lval, const UT_ECurve *curve=0);
00033
00034
00035
00036
00037 static void genRandom(UT_VeryLong &rnd,
00038 const unsigned seed[], unsigned seedlen,
00039 const UT_ECurve *curve=0);
00040
00041
00042
00043
00044
00045 static bool genRandomRaw(UT_VeryLong &rnd,
00046 const unsigned seed[], unsigned seedlen,
00047 const UT_ECurve *curve=0);
00048
00049
00050
00051
00052
00053
00054
00055
00056 void genPubXY(UT_VeryLong &codea,
00057 const UT_VeryLong &rnd) const ;
00058 int encode(UT_VeryLong &codea, UT_VeryLong &codeb,
00059 const UT_VeryLong &rnd,
00060 const UT_VeryLong &message) const;
00061 int encode(UT_VeryLong &codeb,
00062 const unsigned seed[], unsigned seedlen,
00063 const UT_VeryLong &message) const;
00064 UT_VeryLong myKey;
00065 const UT_ECurve *myCurve;
00066 };
00067
00068 class UT_API UT_ECCPublicKey {
00069 public:
00070 UT_ECCPublicKey(const UT_ECCPrivateKey &pkey);
00071 UT_ECCPublicKey(const unsigned int *x, int nxwords,
00072 const unsigned int *y, int nywords,
00073 const UT_ECurve *curve = 0);
00074 UT_ECCPublicKey(const UT_VeryLong &x, const UT_VeryLong &y,
00075 const UT_ECurve *curve = 0);
00076
00077 static void printCode(UT_WorkBuffer &buf, const UT_VeryLong &codea,
00078 const UT_VeryLong &codeb);
00079 static int scanCode(const char *buffer, UT_VeryLong &codea,
00080 UT_VeryLong &codeb);
00081
00082 int decode(const UT_VeryLong &message,
00083 const UT_VeryLong &codea,
00084 const UT_VeryLong &codeb) const;
00085
00086 UT_PolyField myX, myY;
00087 const UT_ECurve *myCurve;
00088 };
00089
00090 #endif