You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@milagro.apache.org by br...@apache.org on 2018/11/07 23:50:15 UTC
[38/51] [partial] incubator-milagro-crypto git commit: update code
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/cs/ROM.cs
----------------------------------------------------------------------
diff --git a/cs/ROM.cs b/cs/ROM.cs
deleted file mode 100644
index 2daf906..0000000
--- a/cs/ROM.cs
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-/* Fixed Data in ROM - Field and Curve parameters */
-
-public class ROM
-{
-/* Don't Modify from here... */
- public const int NOT_SPECIAL = 0;
- public const int PSEUDO_MERSENNE = 1;
- public const int MONTGOMERY_FRIENDLY = 2;
- public const int WEIERSTRASS = 0;
- public const int EDWARDS = 1;
- public const int MONTGOMERY = 2;
-/* ...to here */
-
-/// <summary>
-///* Enter Some Field details here ** </summary>
-// BN Curve
- public const int MODBITS = 254; // Number of bits in Modulus
- public const int MOD8 = 3; // Modulus mod 8
-// Curve 25519
-// public static final int MODBITS=255;
-// public static final int MOD8=5;
-// NIST256 or Brainpool
-// public static final int MODBITS=256;
-// public static final int MOD8=7;
-// MF254
-// public static final int MODBITS=254;
-// public static final int MOD8=7;
-// MS255
-//public static final int MODBITS= 255;
-//public static final int MOD8= 3;
-// MF256
-// public static final int MODBITS=256;
-// public static final int MOD8=7;
-// MS256
-//public static final int MODBITS= 256;
-//public static final int MOD8= 3;
-// ANSSI
-// public static final int MODBITS= 256;
-// public static final int MOD8= 3;
-
-/* Don't Modify from here... */
- public const int NLEN = 5;
- public const int CHUNK = 64;
- public static readonly int DNLEN = 2 * NLEN;
- public const int BASEBITS = 56;
- public static readonly long MASK = (((long)1 << BASEBITS) - 1);
- public static readonly int HBITS = BASEBITS / 2;
- public static readonly long HMASK = (((long)1 << HBITS) - 1);
- public const int MODBYTES = 32;
- public static readonly int NEXCESS = ((int)1 << (CHUNK - BASEBITS - 1));
- public static readonly long FEXCESS = ((long)1 << (BASEBITS * NLEN - MODBITS));
- public static readonly long OMASK = (long)(-1) << (MODBITS % BASEBITS);
- public static readonly int TBITS = MODBITS % BASEBITS; // Number of active bits in top word
- public static readonly long TMASK = ((long)1 << TBITS) - 1;
-/* ...to here */
-
-/* Finite field support - for RSA, DH etc. */
- public const int FF_BITS = 2048; // Finite Field Size in bits - must be 256.2^n
- public static readonly int FFLEN = (FF_BITS / 256);
- public static readonly int HFLEN = (FFLEN / 2); // Useful for half-size RSA private key operations
-
-
-// START SPECIFY FIELD DETAILS HERE
-//*********************************************************************************
-// Curve25519 Modulus
-// public static final int MODTYPE=PSEUDO_MERSENNE;
-// public static final long[] Modulus= {0xFFFFFFFFFFFFEDL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0x7FFFFFFFL};
-// public static final long MConst=0x13L;
-
-
-// NIST-256 Curve
-// public static final int MODTYPE=NOT_SPECIAL;
-// public static final long[] Modulus= {0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFL,0x0L,0x1000000L,0xFFFFFFFFL};
-// public static final long MConst=0x1L;
-
-// MF254 Modulus
-// public static final int MODTYPE=MONTGOMERY_FRIENDLY;
-// public static final long[] Modulus= {0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0x3F80FFFFL};
-// public static final long MConst=0x3F810000L;
-
-// MS255 Modulus
-//public static final int MODTYPE= 1;
-//public static final long[] Modulus= {0xFFFFFFFFFFFD03L,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0x7FFFFFFFL};
-//public static final long MConst=0x2FDL;
-
-// MS256 Modulus
-//public static final int MODTYPE= 1;
-//public static final long[] Modulus= {0xFFFFFFFFFFFF43L,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFL};
-//public static final long MConst=0xBDL;
-
-// MF256 Modulus
-//public static final int MODTYPE= 2;
-//public static final long[] Modulus= {0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFA7FFFFL};
-//public static final long MConst=0xFFA80000L;
-
-// Brainpool
-// public static final int MODTYPE= NOT_SPECIAL;
-// public static final long[] Modulus= {0x13481D1F6E5377L,0xF623D526202820L,0x909D838D726E3BL,0xA1EEA9BC3E660AL,0xA9FB57DBL};
-// public static final long MConst=0xA75590CEFD89B9L;
-
-// ANSSI
-// public static final int MODTYPE= 0;
-// public static final long[] Modulus= {0xFCF353D86E9C03L,0xADBCABC8CA6DE8L,0xE8CE42435B3961L,0xB3AD58F10126DL,0xF1FD178CL};
-// public static final long MConst=0x97483A164E1155L;
-
-// BNCX Curve Modulus
-public const int MODTYPE = NOT_SPECIAL;
-public static readonly long[] Modulus = new long[] {0x6623EF5C1B55B3L,0xD6EE18093EE1BEL,0x647A6366D3243FL,0x8702A0DB0BDDFL,0x24000000L};
-public const long MConst = 0x4E205BF9789E85L;
-
-// BN Curve
-//public static final int MODTYPE=NOT_SPECIAL;
-//public static final long[] Modulus= {0x13L,0x13A7L,0x80000000086121L,0x40000001BA344DL,0x25236482L};
-//public static final long MConst=0x435E50D79435E5L;
-
-// BNT Curve
-//public static final int MODTYPE=NOT_SPECIAL;
-//public static final long[] Modulus= {0x9DBBFEEEB4A713L,0x555614F464BABEL,0x3696F8D5F06E8AL,0x6517014EFA0BABL,0x240120DBL};
-//public static final long MConst=0xC5A872D914C4E5L;
-
-// BNT2 Curve
-//public static final int MODTYPE=NOT_SPECIAL;
-//public static final long[] Modulus= {0xB2DC2BB460A48BL,0x93E428F0D651E8L,0xF3B89D00081CFL,0x410F5AADB74E20L,0x24000482L};
-//public static final long MConst=0xFE6A47A6505CDDL;
-
-// START SPECIFY CURVE DETAILS HERE
-//*********************************************************************************
-
-// Ed25519 Curve
-// public static final int CURVETYPE=EDWARDS;
-// public static final int CURVE_A = -1;
-// public static final long[] CURVE_B = {0xEB4DCA135978A3L,0xA4D4141D8AB75L,0x797779E8980070L,0x2B6FFE738CC740L,0x52036CEEL};
-// public static final long[] CURVE_Order={0x12631A5CF5D3EDL,0xF9DEA2F79CD658L,0x14DEL,0x0L,0x10000000L};
-// public static final long[] CURVE_Gx ={0x562D608F25D51AL,0xC7609525A7B2C9L,0x31FDD6DC5C692CL,0xCD6E53FEC0A4E2L,0x216936D3L};
-// public static final long[] CURVE_Gy ={0x66666666666658L,0x66666666666666L,0x66666666666666L,0x66666666666666L,0x66666666L};
-
-// Original Curve25519
-// public static final int CURVETYPE=MONTGOMERY;
-// public static final int CURVE_A =486662;
-// public static final long[] CURVE_B = {0x0L,0x0L,0x0L,0x0L,0x0L}; // not used
-// public static final long[] CURVE_Order={0x12631A5CF5D3EDL,0xF9DEA2F79CD658L,0x14DEL,0x0L,0x10000000L};
-// public static final long[] CURVE_Gx ={0x9L,0x0L,0x0L,0x0L,0x0L};
-// public static final long[] CURVE_Gy ={0x0L,0x0L,0x0L,0x0L,0x0L}; // not used
-
-// NIST-256 Curve
-// public static final int CURVETYPE=WEIERSTRASS;
-// public static final int CURVE_A = -3;
-// public static final long[] CURVE_B = {0xCE3C3E27D2604BL,0x6B0CC53B0F63BL,0x55769886BC651DL,0xAA3A93E7B3EBBDL,0x5AC635D8L};
-// public static final long[] CURVE_Order={0xB9CAC2FC632551L,0xFAADA7179E84F3L,0xFFFFFFFFFFBCE6L,0xFFFFFFL,0xFFFFFFFFL};
-// public static final long[] CURVE_Gx ={0xA13945D898C296L,0x7D812DEB33A0F4L,0xE563A440F27703L,0xE12C4247F8BCE6L,0x6B17D1F2L};
-// public static final long[] CURVE_Gy ={0xB6406837BF51F5L,0x33576B315ECECBL,0x4A7C0F9E162BCEL,0xFE1A7F9B8EE7EBL,0x4FE342E2L};
-
-// MF254 Modulus, Weierstrass Curve w-254-mont
-//public static final int CURVETYPE= 0;
-//public static final int CURVE_A = -3;
-//public static final long[] CURVE_B = {0xFFFFFFFFFFD08DL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0x3F80FFFFL};
-//public static final long[] CURVE_Order={0xA419C4AF8DF83FL,0x8BEA0DA375C06FL,0xFFFFFFFFFFEB81L,0xFFFFFFFFFFFFFFL,0x3F80FFFFL};
-//public static final long[] CURVE_Gx ={0x2L,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Gy ={0x65DF37F90D4EBCL,0x38E3F8511931ADL,0x75BD778AEBDFB7L,0x3B2E56014AE15AL,0x140E3FD3L};
-
-// MF254 Modulus, Edwards Curve ed-254-mont
-//public static final int CURVETYPE= 1;
-//public static final int CURVE_A = -1;
-//public static final long[] CURVE_B = {0x367BL,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Order={0xF3D3FEC46E98C7L,0x306C8BD62FB0EAL,0xFFFFFFFFFFEB95L,0xFFFFFFFFFFFFFFL,0xFE03FFFL};
-//public static final long[] CURVE_Gx ={0x1L,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Gy ={0x52D0FDAF2701E5L,0x9A840E3212187CL,0xD502363F4E3632L,0xD6A4C335951D00L,0x19F0E690L};
-
-// MF254 Modulus, Montgomery Curve
-// public static final int CURVETYPE=MONTGOMERY;
-// public static final int CURVE_A =-55790;
-// public static final long[] CURVE_B = {0x0L,0x0L,0x0L,0x0L,0x0L}; // not used
-// public static final long[] CURVE_Order={0xF3D3FEC46E98C7L,0x306C8BD62FB0EAL,0xFFFFFFFFFFEB95L,0xFFFFFFFFFFFFFFL,0xFE03FFFL};
-// public static final long[] CURVE_Gx ={0x3L,0x0L,0x0L,0x0L,0x0L};
-// public static final long[] CURVE_Gy ={0x0L,0x0L,0x0L,0x0L,0x0L}; // not used
-
-// MS255 Modulus, Weierstrass Curve
-//public static final int CURVETYPE= 0;
-//public static final int CURVE_A = -3;
-//public static final long[] CURVE_B = {0xFFFFFFFFFFAB46L,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFFFFFFFL,0x7FFFFFFFL};
-//public static final long[] CURVE_Order={0x8FAC983C594AEBL,0x38283AD2B3DFABL,0xFFFFFFFFFF864AL,0xFFFFFFFFFFFFFFL,0x7FFFFFFFL};
-//public static final long[] CURVE_Gx ={0x1L,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Gy ={0x33FF6769CB44BAL,0xC78CDDFDA60D17L,0xF9B2FF7D177DB6L,0xEDBA7833921EBFL,0x6F7A6AC0L};
-
-// MS255 Modulus, Edwards Curve
-//public static final int CURVETYPE= 1;
-//public static final int CURVE_A = -1;
-//public static final long[] CURVE_B = {0xEA97L,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Order={0x49D1ED0436EB75L,0xA785EDA6832EACL,0xFFFFFFFFFFDCF1L,0xFFFFFFFFFFFFFFL,0x1FFFFFFFL};
-//public static final long[] CURVE_Gx ={0x4L,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Gy ={0x2A255BD08736A0L,0x4B8AED445A45BAL,0xDD8E0C47E55291L,0x4A7BB545EC254CL,0x26CB7853L};
-
-// MS255 Modulus, Montgomery Curve
-// public static final int CURVETYPE=MONTGOMERY;
-// public static final int CURVE_A =-240222;
-// public static final long[] CURVE_B = {0x0L,0x0L,0x0L,0x0L,0x0L}; // not used
-// public static final long[] CURVE_Order={0x49D1ED0436EB75L,0xA785EDA6832EACL,0xFFFFFFFFFFDCF1L,0xFFFFFFFFFFFFFFL,0x1FFFFFFFL};
-// public static final long[] CURVE_Gx ={0x4L,0x0L,0x0L,0x0L,0x0L};
-// public static final long[] CURVE_Gy ={0x0L,0x0L,0x0L,0x0L,0x0L}; // not used
-
-// MS256, Weierstrass Curve
-//public static final int CURVETYPE= 0;
-//public static final int CURVE_A = -3;
-//public static final long[] CURVE_B = {0x25581L,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Order={0xAB20294751A825L,0x8275EA265C6020L,0xFFFFFFFFFFE43CL,0xFFFFFFFFFFFFFFL,0xFFFFFFFFL};
-//public static final long[] CURVE_Gx ={0x1L,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Gy ={0xF46306C2B56C77L,0x2F9375894EC10BL,0x6CCEEEDD6BD02CL,0xC1E466D7FC82C9L,0x696F1853L};
-
-// MS256, Edwards Curve
-//public static final int CURVETYPE= 1;
-//public static final int CURVE_A = -1;
-//public static final long[] CURVE_B = {0x3BEEL,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Order={0xB84E6F1122B4ADL,0xA55AD0A6BC64E5L,0xFFFFFFFFFFBE6AL,0xFFFFFFFFFFFFFFL,0x3FFFFFFFL};
-//public static final long[] CURVE_Gx ={0xDL,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Gy ={0x7F6FB5331CADBAL,0x6D63824D303F70L,0xB39FA046BFBE2AL,0x2A1276DBA3D330L,0x7D0AB41EL};
-
-// MS256 Modulus, Montgomery Curve
-// public static final int CURVETYPE=MONTGOMERY;
-// public static final int CURVE_A =-61370;
-// public static final long[] CURVE_B = {0x0L,0x0L,0x0L,0x0L,0x0L}; // not used
-// public static final long[] CURVE_Order={0xB84E6F1122B4ADL,0xA55AD0A6BC64E5L,0xFFFFFFFFFFBE6AL,0xFFFFFFFFFFFFFFL,0x3FFFFFFFL};
-// public static final long[] CURVE_Gx ={0xbL,0x0L,0x0L,0x0L,0x0L};
-// public static final long[] CURVE_Gy ={0x0L,0x0L,0x0L,0x0L,0x0L}; // not used
-
-// MF256 Modulus, Weierstrass Curve
-//public static final int CURVETYPE= 0;
-//public static final int CURVE_A = -3;
-//public static final long[] CURVE_B = {0x14E6AL,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Order={0x10C5E1A79857EBL,0x7513E6E5074B9DL,0xFFFFFFFFFFFC51L,0xFFFFFFFFFFFFFFL,0xFFA7FFFFL};
-//public static final long[] CURVE_Gx ={0x1L,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Gy ={0x7954C2B724D2AL,0x47EB8D94DC6610L,0x26123DAE289569L,0xBE1808CE7BABBAL,0x20887C87L};
-
-// MF256, Edwards Curve
-//public static final int CURVETYPE= 1;
-//public static final int CURVE_A = -1;
-//public static final long[] CURVE_B = {0x350AL,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Order={0xD92EDED8EC7BABL,0xBBAFB86733C966L,0xFFFFFFFFFFB154L,0xFFFFFFFFFFFFFFL,0x3FE9FFFFL};
-//public static final long[] CURVE_Gx ={0x1L,0x0L,0x0L,0x0L,0x0L};
-//public static final long[] CURVE_Gy ={0xEAA722F2F3C908L,0x5E648DFEA68D7DL,0xF3DB2C1AACA0C0L,0xF8CC4D5AEAEBEEL,0xDAD8D4F8L};
-
-// MF256 Modulus, Montgomery Curve
-// public static final int CURVETYPE=MONTGOMERY;
-// public static final int CURVE_A =-54314;
-// public static final long[] CURVE_B = {0x0L,0x0L,0x0L,0x0L,0x0L}; // not used
-// public static final long[] CURVE_Order={0xD92EDED8EC7BABL,0xBBAFB86733C966L,0xFFFFFFFFFFB154L,0xFFFFFFFFFFFFFFL,0x3FE9FFFFL};
-// public static final long[] CURVE_Gx ={0x8L,0x0L,0x0L,0x0L,0x0L};
-// public static final long[] CURVE_Gy ={0x0L,0x0L,0x0L,0x0L,0x0L}; // not used
-
-
-
-// Brainpool
-// public static final int CURVETYPE= 0;
-// public static final int CURVE_A = -3;
-// public static final long[] CURVE_B = {0xE58101FEE92B04L,0xEBC4AF2F49256AL,0x733D0B76B7BF93L,0x30D84EA4FE66A7L,0x662C61C4L};
-// public static final long[] CURVE_Order={0x1E0E82974856A7L,0x7AA3B561A6F790L,0x909D838D718C39L,0xA1EEA9BC3E660AL,0xA9FB57DBL};
-// public static final long[] CURVE_Gx ={0xA191562E1305F4L,0x42C47AAFBC2B79L,0xB23A656149AFA1L,0xC1CFE7B7732213L,0xA3E8EB3CL};
-// public static final long[] CURVE_Gy ={0xABE8F35B25C9BEL,0xB6DE39D027001DL,0xE14644417E69BCL,0x3439C56D7F7B22L,0x2D996C82L};
-
-// ANSSI
-// public static final int CURVETYPE= 0;
-// public static final int CURVE_A = -3;
-// public static final long[] CURVE_B = {0x75ED967B7BB73FL,0xC9AE4B1A18030L,0x754A44C00FDFECL,0x5428A9300D4ABAL,0xEE353FCAL};
-// public static final long[] CURVE_Order={0xFDD459C6D655E1L,0x67E140D2BF941FL,0xE8CE42435B53DCL,0xB3AD58F10126DL,0xF1FD178CL};
-// public static final long[] CURVE_Gx ={0xC97A2DD98F5CFFL,0xD2DCAF98B70164L,0x4749D423958C27L,0x56C139EB31183DL,0xB6B3D4C3L};
-// public static final long[] CURVE_Gy ={0x115A1554062CFBL,0xC307E8E4C9E183L,0xF0F3ECEF8C2701L,0xC8B204911F9271L,0x6142E0F7L};
-
-// BNCX Curve
-
- public const int CURVETYPE = WEIERSTRASS;
- public const int CURVE_A = 0;
- public static readonly long[] CURVE_B = new long[] {0x2L,0x0L,0x0L,0x0L,0x0L};
- public static readonly long[] CURVE_Order = new long[] {0x11C0A636EB1F6DL,0xD6EE0CC906CEBEL,0x647A6366D2C43FL,0x8702A0DB0BDDFL,0x24000000L};
- public static readonly long[] CURVE_Bnx = new long[] {0x3C012B1L,0x40L,0x0L,0x0L,0x0L};
- public static readonly long[] CURVE_Cru = new long[] {0xE0931794235C97L,0xDF6471EF875631L,0xCA83F1440BDL,0x480000L,0x0L};
- public static readonly long[] CURVE_Fra = new long[] {0xD9083355C80EA3L,0x7326F173F8215BL,0x8AACA718986867L,0xA63A0164AFE18BL,0x1359082FL};
- public static readonly long[] CURVE_Frb = new long[] {0x8D1BBC06534710L,0x63C7269546C062L,0xD9CDBC4E3ABBD8L,0x623628A900DC53L,0x10A6F7D0L};
- public static readonly long[] CURVE_Pxa = new long[] {0x851CEEE4D2EC74L,0x85BFA03E2726C0L,0xF5C34BBB907CL,0x7053B256358B25L,0x19682D2CL};
- public static readonly long[] CURVE_Pxb = new long[] {0xA58E8B2E29CFE1L,0x97B0C209C30F47L,0x37A8E99743F81BL,0x3E19F64AA011C9L,0x1466B9ECL};
- public static readonly long[] CURVE_Pya = new long[] {0xFBFCEBCF0BE09FL,0xB33D847EC1B30CL,0x157DAEE2096361L,0x72332B8DD81E22L,0xA79EDD9L};
- public static readonly long[] CURVE_Pyb = new long[] {0x904B228898EE9DL,0x4EA569D2EDEBEDL,0x512D8D3461C286L,0xECC4C09035C6E4L,0x6160C39L};
- public static readonly long[] CURVE_Gx = new long[] {0x6623EF5C1B55B2L,0xD6EE18093EE1BEL,0x647A6366D3243FL,0x8702A0DB0BDDFL,0x24000000L};
- public static readonly long[] CURVE_Gy = new long[] {0x1L,0x0L,0x0L,0x0L,0x0L};
- public static readonly long[][] CURVE_W = new long[][]
- {
- new long[] {0x546349162FEB83L,0xB40381200L,0x6000L,0x0L,0x0L},
- new long[] {0x7802561L,0x80L,0x0L,0x0L,0x0L}
- };
- public static readonly long[][][] CURVE_SB = new long[][][]
- {
- new long[][]
- {
- new long[] {0x5463491DB010E4L,0xB40381280L,0x6000L,0x0L,0x0L},
- new long[] {0x7802561L,0x80L,0x0L,0x0L,0x0L}
- },
- new long[][]
- {
- new long[] {0x7802561L,0x80L,0x0L,0x0L,0x0L},
- new long[] {0xBD5D5D20BB33EAL,0xD6EE0188CEBCBDL,0x647A6366D2643FL,0x8702A0DB0BDDFL,0x24000000L}
- }
- };
- public static readonly long[][] CURVE_WB = new long[][]
- {
- new long[] {0x1C2118567A84B0L,0x3C012B040L,0x2000L,0x0L,0x0L},
- new long[] {0xCDF995BE220475L,0x94EDA8CA7F9A36L,0x8702A0DC07EL,0x300000L,0x0L},
- new long[] {0x66FCCAE0F10B93L,0x4A76D4653FCD3BL,0x4381506E03FL,0x180000L,0x0L},
- new long[] {0x1C21185DFAAA11L,0x3C012B0C0L,0x2000L,0x0L,0x0L}
- };
- public static readonly long[][][] CURVE_BB = new long[][][]
- {
- new long[][]
- {
- new long[] {0x11C0A6332B0CBDL,0xD6EE0CC906CE7EL,0x647A6366D2C43FL,0x8702A0DB0BDDFL,0x24000000L},
- new long[] {0x11C0A6332B0CBCL,0xD6EE0CC906CE7EL,0x647A6366D2C43FL,0x8702A0DB0BDDFL,0x24000000L},
- new long[] {0x11C0A6332B0CBCL,0xD6EE0CC906CE7EL,0x647A6366D2C43FL,0x8702A0DB0BDDFL,0x24000000L},
- new long[] {0x7802562L,0x80L,0x0L,0x0L,0x0L}
- },
- new long[][]
- {
- new long[] {0x7802561L,0x80L,0x0L,0x0L,0x0L},
- new long[] {0x11C0A6332B0CBCL,0xD6EE0CC906CE7EL,0x647A6366D2C43FL,0x8702A0DB0BDDFL,0x24000000L},
- new long[] {0x11C0A6332B0CBDL,0xD6EE0CC906CE7EL,0x647A6366D2C43FL,0x8702A0DB0BDDFL,0x24000000L},
- new long[] {0x11C0A6332B0CBCL,0xD6EE0CC906CE7EL,0x647A6366D2C43FL,0x8702A0DB0BDDFL,0x24000000L}
- },
- new long[][]
- {
- new long[] {0x7802562L,0x80L,0x0L,0x0L,0x0L},
- new long[] {0x7802561L,0x80L,0x0L,0x0L,0x0L},
- new long[] {0x7802561L,0x80L,0x0L,0x0L,0x0L},
- new long[] {0x7802561L,0x80L,0x0L,0x0L,0x0L}
- },
- new long[][]
- {
- new long[] {0x3C012B2L,0x40L,0x0L,0x0L,0x0L},
- new long[] {0xF004AC2L,0x100L,0x0L,0x0L,0x0L},
- new long[] {0x11C0A62F6AFA0AL,0xD6EE0CC906CE3EL,0x647A6366D2C43FL,0x8702A0DB0BDDFL,0x24000000L},
- new long[] {0x3C012B2L,0x40L,0x0L,0x0L,0x0L}
- }
- };
-
- public const bool USE_GLV = true;
- public const bool USE_GS_G2 = true;
- public const bool USE_GS_GT = true;
- public const bool GT_STRONG = true;
-
-// BNT Curve
-/*
-public static final int CURVETYPE=WEIERSTRASS;
-public static final int CURVE_A = 0;
-public static final long[] CURVE_B = {0x2L,0x0L,0x0L,0x0L,0x0L};
-public static final long[] CURVE_Order={0x75777E8D30210DL,0xD43492B2CB363AL,0x3696F8D5F00E88L,0x6517014EFA0BABL,0x240120DBL};
-public static final long[] CURVE_Bnx={0x806000004081L,0x40L,0x0L,0x0L,0x0L};
-public static final long[] CURVE_Cru={0xEB53D5AB4FCD87L,0x82A5F2BAB11FADL,0x47651504C9764CL,0x4801B1L,0x0L};
-public static final long[] CURVE_Fra={0xF5D14EADC80022L,0x4904D6FACCE359L,0xF190A13211BE6CL,0xC9BBC4394F6509L,0x1328A292L};
-public static final long[] CURVE_Frb={0xA7EAB040ECA6F1L,0xC513DF997D764L,0x450657A3DEB01EL,0x9B5B3D15AAA6A1L,0x10D87E48L};
-public static final long[] CURVE_Pxa={0x8987E2288E65BBL,0xAD1CAA6313BEL,0x325041548B7CCCL,0x4C1339EBCC055L,0x14483FCDL};
-public static final long[] CURVE_Pxb={0x67888808DBE2C0L,0x7FE1F81E34853AL,0xA631A51B57B95L,0x384EC302DA3FC5L,0x87F46B3L};
-public static final long[] CURVE_Pya={0x202C47E020CA1DL,0xB4167E8399F36CL,0xC6E5439F72C94CL,0x102B0BD74A2C69L,0x14E8C29CL};
-public static final long[] CURVE_Pyb={0xD8437C716628F2L,0x27E167BCB7DC6BL,0xA82C7572681D0AL,0x62454BD1EDEC18L,0x17AFE2A4L};
-public static final long[] CURVE_Gx ={0x9DBBFEEEB4A712L,0x555614F464BABEL,0x3696F8D5F06E8AL,0x6517014EFA0BABL,0x240120DBL};
-public static final long[] CURVE_Gy ={0x1L,0x0L,0x0L,0x0L,0x0L};
-public static final long[][] CURVE_W={{0x26430061838403L,0x81218241998384L,0x6001L,0x0L,0x0L},{0x100C000008101L,0x80L,0x0L,0x0L,0x0L}};
-public static final long[][][] CURVE_SB={{{0x2743C061840504L,0x81218241998404L,0x6001L,0x0L,0x0L},{0x100C000008101L,0x80L,0x0L,0x0L,0x0L}},{{0x100C000008101L,0x80L,0x0L,0x0L,0x0L},{0x4F347E2BAC9D0AL,0x5313107131B2B6L,0x3696F8D5EFAE87L,0x6517014EFA0BABL,0x240120DBL}}};
-public static final long[][] CURVE_WB={{0x6140602080C080L,0x806080C08880C1L,0x2000L,0x0L,0x0L},{0xB53904088C4A85L,0xAD2FA352DC6C36L,0xDA436358868EDEL,0x300120L,0x0L},{0x5ADCB204464583L,0x5697D1A96E363BL,0x6D21B1AC43476FL,0x180090L,0x0L},{0x62412020814181L,0x806080C0888141L,0x2000L,0x0L,0x0L}};
-public static final long[][][] CURVE_BB={{{0x74F71E8D2FE08DL,0xD43492B2CB35FAL,0x3696F8D5F00E88L,0x6517014EFA0BABL,0x240120DBL},{0x74F71E8D2FE08CL,0xD43492B2CB35FAL,0x3696F8D5F00E88L,0x6517014EFA0BABL,0x240120DBL},{0x74F71E8D2FE08CL,0xD43492B2CB35FAL,0x3696F8D5F00E88L,0x6517014EFA0BABL,0x240120DBL},{0x100C000008102L,0x80L,0x0L,0x0L,0x0L}},{{0x100C000008101L,0x80L,0x0L,0x0L,0x0L},{0x74F71E8D2FE08CL,0xD43492B2CB35FAL,0x3696F8D5F00E88L,0x6517014EFA0BABL,0x240120DBL},{0x74F71E8D2FE08DL,0xD43492B2CB35FAL,0x3696F8D5F00E88L,0x6517014EFA0BABL,0x240120DBL},{0x74F71E8D2FE08CL,0xD43492B2CB35FAL,0x3696F8D5F00E88L,0x6517014EFA0BABL,0x240120DBL}},{{0x100C000008102L,0x80L,0x0L,0x0L,0x0L},{0x100C000008101L,0x80L,0x0L,0x0L,0x0L},{0x100C000008101L,0x80L,0x0L,0x0L,0x0L},{0x100C000008101L,0x80L,0x0L,0x0L,0x0L}},{{0x806000004082L,0x40L,0x0L,0x0L,0x0L},{0x2018000010202L,0x100L,0x0L,0x0L,0x0L},{0x7476BE8D2FA00AL,0xD43492B2CB35BAL,0x3696F8D5F00E88L,0x6517014EFA0BABL,0x240120DBL},{0x806000004082L,0x40L,0x0L
,0x0L,0x0L}}};
-
-*/
-
-// BNT2 Curve
-/*
- public static final int CURVETYPE=WEIERSTRASS;
- public static final int CURVE_A = 0;
- public static final long[] CURVE_B = {0x2L,0x0L,0x0L,0x0L,0x0L};
- public static final long[] CURVE_Order={0xFB71A511AA2BF5L,0x8DE127B73833D7L,0xF3B89D00021CFL,0x410F5AADB74E20L,0x24000482L};
- public static final long[] CURVE_Bnx={0x20100608205L,0x40L,0x0L,0x0L,0x0L};
- public static final long[] CURVE_Cru={0x5027444866BD33L,0x5B773016470EFBL,0xC3617BECF23675L,0x480006L,0x0L};
- public static final long[] CURVE_Fra={0xB268C973AEF062L,0xC69B33C3BCE492L,0xF67FA37F195BBCL,0x29E8CAB6BD0A41L,0x124E0B8DL};
- public static final long[] CURVE_Frb={0x736240B1B429L,0xCD48F52D196D56L,0x18BBE650E72612L,0x17268FF6FA43DEL,0x11B1F8F5L};
- public static final long[] CURVE_Pxa={0xCC92399F40A3C8L,0xCDA4E96611784AL,0x7B056961706B35L,0x9693C6318279D7L,0x16FC17CFL};
- public static final long[] CURVE_Pxb={0x557A8AD8549540L,0x6F7BE6F6510610L,0x565907A95D17DBL,0xBD5975909C8188L,0x1EB5B500L};
- public static final long[] CURVE_Pya={0x7BECC514220513L,0x4A78860E737B14L,0x51B83935F12684L,0x761422AA9D4DFAL,0x1E8EE498L};
- public static final long[] CURVE_Pyb={0xB9328F577CE78EL,0xB746E26FA5781FL,0xA93DBC1FB8E27EL,0xBAE33BDBA29D76L,0x23CEF4CDL};
- public static final long[] CURVE_Gx ={0xB2DC2BB460A48AL,0x93E428F0D651E8L,0xF3B89D00081CFL,0x410F5AADB74E20L,0x24000482L};
- public static final long[] CURVE_Gy ={0x1L,0x0L,0x0L,0x0L,0x0L};
- public static final long[][] CURVE_W={{0xB76282A1347083L,0x60301399E1D10L,0x6000L,0x0L,0x0L},{0x40200C10409L,0x80L,0x0L,0x0L,0x0L}};
- public static final long[][][] CURVE_SB={{{0xB76684A1F5748CL,0x60301399E1D90L,0x6000L,0x0L,0x0L},{0x40200C10409L,0x80L,0x0L,0x0L,0x0L}},{{0x40200C10409L,0x80L,0x0L,0x0L,0x0L},{0x440F227075BB72L,0x87DE267D9A16C7L,0xF3B89CFFFC1CFL,0x410F5AADB74E20L,0x24000482L}}};
- public static final long[][] CURVE_WB={{0x9272D48A70A224L,0x20100688A0945L,0x2000L,0x0L,0x0L},{0x5A572CF030EF19L,0x9651763543721DL,0x8240FD48A1B9A3L,0x300004L,0x0L},{0xAD2C96F848B88FL,0xCB28BB1AA1B92EL,0x41207EA450DCD1L,0x180002L,0x0L},{0x9276D68B31A62DL,0x20100688A09C5L,0x2000L,0x0L,0x0L}};
- public static final long[][][] CURVE_BB={{{0xFB6FA41149A9F1L,0x8DE127B7383397L,0xF3B89D00021CFL,0x410F5AADB74E20L,0x24000482L},{0xFB6FA41149A9F0L,0x8DE127B7383397L,0xF3B89D00021CFL,0x410F5AADB74E20L,0x24000482L},{0xFB6FA41149A9F0L,0x8DE127B7383397L,0xF3B89D00021CFL,0x410F5AADB74E20L,0x24000482L},{0x40200C1040AL,0x80L,0x0L,0x0L,0x0L}},{{0x40200C10409L,0x80L,0x0L,0x0L,0x0L},{0xFB6FA41149A9F0L,0x8DE127B7383397L,0xF3B89D00021CFL,0x410F5AADB74E20L,0x24000482L},{0xFB6FA41149A9F1L,0x8DE127B7383397L,0xF3B89D00021CFL,0x410F5AADB74E20L,0x24000482L},{0xFB6FA41149A9F0L,0x8DE127B7383397L,0xF3B89D00021CFL,0x410F5AADB74E20L,0x24000482L}},{{0x40200C1040AL,0x80L,0x0L,0x0L,0x0L},{0x40200C10409L,0x80L,0x0L,0x0L,0x0L},{0x40200C10409L,0x80L,0x0L,0x0L,0x0L},{0x40200C10409L,0x80L,0x0L,0x0L,0x0L}},{{0x20100608206L,0x40L,0x0L,0x0L,0x0L},{0x80401820812L,0x100L,0x0L,0x0L,0x0L},{0xFB6DA310E927EAL,0x8DE127B7383357L,0xF3B89D00021CFL,0x410F5AADB74E20L,0x24000482L},{0x20100608206L,0x40L,0x0L,0x0L,0x0L}}};
-*/
-
-// BN Curve
-/*
-public static final int CURVETYPE=WEIERSTRASS;
-public static final int CURVE_A = 0;
-public static final long[] CURVE_B = {0x2L,0x0L,0x0L,0x0L,0x0L};
-public static final long[] CURVE_Order={0xDL,0x800000000010A1L,0x8000000007FF9FL,0x40000001BA344DL,0x25236482L};
-public static final long[] CURVE_Bnx={0x80000000000001L,0x40L,0x0L,0x0L,0x0L};
-public static final long[] CURVE_Cru={0x80000000000007L,0x6CDL,0x40000000024909L,0x49B362L,0x0L};
-public static final long[] CURVE_Fra={0x7DE6C06F2A6DE9L,0x74924D3F77C2E1L,0x50A846953F8509L,0x212E7C8CB6499BL,0x1B377619L};
-public static final long[] CURVE_Frb={0x82193F90D5922AL,0x8B6DB2C08850C5L,0x2F57B96AC8DC17L,0x1ED1837503EAB2L,0x9EBEE69L};
-public static final long[] CURVE_Pxa={0xAB2C7935FD0CB4L,0xE319E4FCC57C2BL,0x24F6DF763B05A5L,0xF55EA7EA335FB7L,0x95B04D4L};
-public static final long[] CURVE_Pxb={0xA07D0790962455L,0x86BE3D27AA5E38L,0x89E05747F39D6DL,0xC08347B49D42BFL,0x5D4D8A7L};
-public static final long[] CURVE_Pya={0xADCE687A08A46CL,0x2B30E98A4191F9L,0x4C3784B1F16908L,0x25E5313FA16D1CL,0xABF2ABFL};
-public static final long[] CURVE_Pyb={0xDF88D405F306ECL,0x82076ADD13A0E6L,0x1E47819D6A5C04L,0xE679DABDB38627L,0x18769A87L};
-public static final long[] CURVE_Gx ={0x12L,0x13A7L,0x80000000086121L,0x40000001BA344DL,0x25236482L};
-public static final long[] CURVE_Gy ={0x1L,0x0L,0x0L,0x0L,0x0L};
-public static final long[][] CURVE_W={{0x3L,0x80000000000204L,0x6181L,0x0L,0x0L},{0x1L,0x81L,0x0L,0x0L,0x0L}};
-public static final long[][][] CURVE_SB={{{0x4L,0x80000000000285L,0x6181L,0x0L,0x0L},{0x1L,0x81L,0x0L,0x0L,0x0L}},{{0x1L,0x81L,0x0L,0x0L,0x0L},{0xAL,0xE9DL,0x80000000079E1EL,0x40000001BA344DL,0x25236482L}}};
-public static final long[][] CURVE_WB={{0x80000000000000L,0x80000000000040L,0x2080L,0x0L,0x0L},{0x80000000000005L,0x54AL,0x8000000001C707L,0x312241L,0x0L},{0x80000000000003L,0x800000000002C5L,0xC000000000E383L,0x189120L,0x0L},{0x80000000000001L,0x800000000000C1L,0x2080L,0x0L,0x0L}};
-public static final long[][][] CURVE_BB={{{0x8000000000000DL,0x80000000001060L,0x8000000007FF9FL,0x40000001BA344DL,0x25236482L},{0x8000000000000CL,0x80000000001060L,0x8000000007FF9FL,0x40000001BA344DL,0x25236482L},{0x8000000000000CL,0x80000000001060L,0x8000000007FF9FL,0x40000001BA344DL,0x25236482L},{0x2L,0x81L,0x0L,0x0L,0x0L}},{{0x1L,0x81L,0x0L,0x0L,0x0L},{0x8000000000000CL,0x80000000001060L,0x8000000007FF9FL,0x40000001BA344DL,0x25236482L},{0x8000000000000DL,0x80000000001060L,0x8000000007FF9FL,0x40000001BA344DL,0x25236482L},{0x8000000000000CL,0x80000000001060L,0x8000000007FF9FL,0x40000001BA344DL,0x25236482L}},{{0x2L,0x81L,0x0L,0x0L,0x0L},{0x1L,0x81L,0x0L,0x0L,0x0L},{0x1L,0x81L,0x0L,0x0L,0x0L},{0x1L,0x81L,0x0L,0x0L,0x0L}},{{0x80000000000002L,0x40L,0x0L,0x0L,0x0L},{0x2L,0x102L,0x0L,0x0L,0x0L},{0xAL,0x80000000001020L,0x8000000007FF9FL,0x40000001BA344DL,0x25236482L},{0x80000000000002L,0x40L,0x0L,0x0L,0x0L}}};
-
-*/
-
-// public static boolean debug=false;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/cs/RSA.cs
----------------------------------------------------------------------
diff --git a/cs/RSA.cs b/cs/RSA.cs
deleted file mode 100644
index 20c7dcf..0000000
--- a/cs/RSA.cs
+++ /dev/null
@@ -1,443 +0,0 @@
-using System;
-
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-/* RSA API high-level functions */
-
-public sealed class rsa_private_key
-{
- public FF p, q, dp, dq, c;
-
- public rsa_private_key(int n)
- {
- p = new FF(n);
- q = new FF(n);
- dp = new FF(n);
- dq = new FF(n);
- c = new FF(n);
- }
-}
-
-public sealed class rsa_public_key
-{
- public int e;
- public FF n;
-
- public rsa_public_key(int m)
- {
- e = 0;
- n = new FF(m);
- }
-}
-
-public sealed class RSA
-{
-
- public static readonly int RFS = ROM.MODBYTES * ROM.FFLEN;
-
-/* generate an RSA key pair */
-
- public static void KEY_PAIR(RAND rng, int e, rsa_private_key PRIV, rsa_public_key PUB)
- { // IEEE1363 A16.11/A16.12 more or less
- int n = PUB.n.getlen() / 2;
- FF t = new FF(n);
- FF p1 = new FF(n);
- FF q1 = new FF(n);
-
- for (;;)
- {
-
- PRIV.p.random(rng);
- while (PRIV.p.lastbits(2) != 3)
- {
- PRIV.p.inc(1);
- }
- while (!FF.prime(PRIV.p,rng))
- {
- PRIV.p.inc(4);
- }
-
- p1.copy(PRIV.p);
- p1.dec(1);
-
- if (p1.cfactor(e))
- {
- continue;
- }
- break;
- }
-
- for (;;)
- {
- PRIV.q.random(rng);
- while (PRIV.q.lastbits(2) != 3)
- {
- PRIV.q.inc(1);
- }
- while (!FF.prime(PRIV.q,rng))
- {
- PRIV.q.inc(4);
- }
-
- q1.copy(PRIV.q);
- q1.dec(1);
-
- if (q1.cfactor(e))
- {
- continue;
- }
-
- break;
- }
-
- PUB.n = FF.mul(PRIV.p,PRIV.q);
- PUB.e = e;
-
- t.copy(p1);
- t.shr();
- PRIV.dp.set(e);
- PRIV.dp.invmodp(t);
- if (PRIV.dp.parity() == 0)
- {
- PRIV.dp.add(t);
- }
- PRIV.dp.norm();
-
- t.copy(q1);
- t.shr();
- PRIV.dq.set(e);
- PRIV.dq.invmodp(t);
- if (PRIV.dq.parity() == 0)
- {
- PRIV.dq.add(t);
- }
- PRIV.dq.norm();
-
- PRIV.c.copy(PRIV.p);
- PRIV.c.invmodp(PRIV.q);
-
- return;
- }
-
-/* Mask Generation Function */
-
- public static void MGF1(sbyte[] Z, int olen, sbyte[] K)
- {
- HASH H = new HASH();
- int hlen = HASH.len;
- sbyte[] B = new sbyte[hlen];
-
- int counter , cthreshold , k = 0;
- for (int i = 0;i < K.Length;i++)
- {
- K[i] = 0;
- }
-
- cthreshold = olen / hlen;
- if (olen % hlen != 0)
- {
- cthreshold++;
- }
- for (counter = 0;counter < cthreshold;counter++)
- {
- H.process_array(Z);
- H.process_num(counter);
- B = H.hash();
-
- if (k + hlen > olen)
- {
- for (int i = 0;i < olen % hlen;i++)
- {
- K[k++] = B[i];
- }
- }
- else
- {
- for (int i = 0;i < hlen;i++)
- {
- K[k++] = B[i];
- }
- }
- }
- }
-
- public static void printBinary(sbyte[] array)
- {
- int i;
- for (i = 0;i < array.Length;i++)
- {
- Console.Write("{0:x2}", array[i]);
- }
- Console.WriteLine();
- }
-
- /* OAEP Message Encoding for Encryption */
- public static sbyte[] OAEP_ENCODE(sbyte[] m, RAND rng, sbyte[] p)
- {
- int i , slen , olen = RFS - 1;
- int mlen = m.Length;
- int hlen, seedlen;
- sbyte[] f = new sbyte[RFS];
-
- HASH H = new HASH();
- hlen = HASH.len;
- sbyte[] SEED = new sbyte[hlen];
- seedlen = hlen;
- if (mlen > olen - hlen - seedlen - 1)
- {
- return new sbyte[0];
- }
-
- sbyte[] DBMASK = new sbyte[olen - seedlen];
-
- if (p != null)
- {
- H.process_array(p);
- }
- sbyte[] h = H.hash();
- for (i = 0;i < hlen;i++)
- {
- f[i] = h[i];
- }
-
- slen = olen - mlen - hlen - seedlen - 1;
-
- for (i = 0;i < slen;i++)
- {
- f[hlen + i] = 0;
- }
- f[hlen + slen] = 1;
- for (i = 0;i < mlen;i++)
- {
- f[hlen + slen + 1 + i] = m[i];
- }
-
- for (i = 0;i < seedlen;i++)
- {
- SEED[i] = (sbyte)rng.Byte;
- }
- MGF1(SEED,olen - seedlen,DBMASK);
-
- for (i = 0;i < olen - seedlen;i++)
- {
- DBMASK[i] ^= f[i];
- }
- MGF1(DBMASK,seedlen,f);
-
- for (i = 0;i < seedlen;i++)
- {
- f[i] ^= SEED[i];
- }
-
- for (i = 0;i < olen - seedlen;i++)
- {
- f[i + seedlen] = DBMASK[i];
- }
-
- /* pad to length RFS */
- int d = 1;
- for (i = RFS - 1;i >= d;i--)
- {
- f[i] = f[i - d];
- }
- for (i = d - 1;i >= 0;i--)
- {
- f[i] = 0;
- }
-
- return f;
- }
-
- /* OAEP Message Decoding for Decryption */
- public static sbyte[] OAEP_DECODE(sbyte[] p, sbyte[] f)
- {
- int x, t;
- bool comp;
- int i , k , olen = RFS - 1;
- int hlen, seedlen;
-
- HASH H = new HASH();
- hlen = HASH.len;
- sbyte[] SEED = new sbyte[hlen];
- seedlen = hlen;
- sbyte[] CHASH = new sbyte[hlen];
-
- if (olen < seedlen + hlen + 1)
- {
- return new sbyte[0];
- }
- sbyte[] DBMASK = new sbyte[olen - seedlen];
- for (i = 0;i < olen - seedlen;i++)
- {
- DBMASK[i] = 0;
- }
-
- if (f.Length < RFS)
- {
- int d = RFS - f.Length;
- for (i = RFS - 1;i >= d;i--)
- {
- f[i] = f[i - d];
- }
- for (i = d - 1;i >= 0;i--)
- {
- f[i] = 0;
- }
-
- }
-
- if (p != null)
- {
- H.process_array(p);
- }
- sbyte[] h = H.hash();
- for (i = 0;i < hlen;i++)
- {
- CHASH[i] = h[i];
- }
-
- x = f[0];
-
- for (i = seedlen;i < olen;i++)
- {
- DBMASK[i - seedlen] = f[i + 1];
- }
-
- MGF1(DBMASK,seedlen,SEED);
- for (i = 0;i < seedlen;i++)
- {
- SEED[i] ^= f[i + 1];
- }
- MGF1(SEED,olen - seedlen,f);
- for (i = 0;i < olen - seedlen;i++)
- {
- DBMASK[i] ^= f[i];
- }
-
- comp = true;
- for (i = 0;i < hlen;i++)
- {
- if (CHASH[i] != DBMASK[i])
- {
- comp = false;
- }
- }
-
- for (i = 0;i < olen - seedlen - hlen;i++)
- {
- DBMASK[i] = DBMASK[i + hlen];
- }
-
- for (i = 0;i < hlen;i++)
- {
- SEED[i] = CHASH[i] = 0;
- }
-
- for (k = 0;;k++)
- {
- if (k >= olen - seedlen - hlen)
- {
- return new sbyte[0];
- }
- if (DBMASK[k] != 0)
- {
- break;
- }
- }
-
- t = DBMASK[k];
- if (!comp || x != 0 || t != 0x01)
- {
- for (i = 0;i < olen - seedlen;i++)
- {
- DBMASK[i] = 0;
- }
- return new sbyte[0];
- }
-
- sbyte[] r = new sbyte[olen - seedlen - hlen - k - 1];
-
- for (i = 0;i < olen - seedlen - hlen - k - 1;i++)
- {
- r[i] = DBMASK[i + k + 1];
- }
-
- for (i = 0;i < olen - seedlen;i++)
- {
- DBMASK[i] = 0;
- }
-
- return r;
- }
-
- /* destroy the Private Key structure */
- public static void PRIVATE_KEY_KILL(rsa_private_key PRIV)
- {
- PRIV.p.zero();
- PRIV.q.zero();
- PRIV.dp.zero();
- PRIV.dq.zero();
- PRIV.c.zero();
- }
-
- /* RSA encryption with the public key */
- public static void ENCRYPT(rsa_public_key PUB, sbyte[] F, sbyte[] G)
- {
- int n = PUB.n.getlen();
- FF f = new FF(n);
-
- FF.fromBytes(f,F);
- f.power(PUB.e,PUB.n);
- f.toBytes(G);
- }
-
- /* RSA decryption with the private key */
- public static void DECRYPT(rsa_private_key PRIV, sbyte[] G, sbyte[] F)
- {
- int n = PRIV.p.getlen();
- FF g = new FF(2 * n);
-
- FF.fromBytes(g,G);
- FF jp = g.dmod(PRIV.p);
- FF jq = g.dmod(PRIV.q);
-
- jp.skpow(PRIV.dp,PRIV.p);
- jq.skpow(PRIV.dq,PRIV.q);
-
- g.zero();
- g.dscopy(jp);
- jp.mod(PRIV.q);
- if (FF.comp(jp,jq) > 0)
- {
- jq.add(PRIV.q);
- }
- jq.sub(jp);
- jq.norm();
-
- FF t = FF.mul(PRIV.c,jq);
- jq = t.dmod(PRIV.q);
-
- t = FF.mul(jq,PRIV.p);
- g.add(t);
- g.norm();
-
- g.toBytes(F);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/cs/RectangularArrays.cs
----------------------------------------------------------------------
diff --git a/cs/RectangularArrays.cs b/cs/RectangularArrays.cs
deleted file mode 100644
index 976a070..0000000
--- a/cs/RectangularArrays.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//----------------------------------------------------------------------------------------
-// Copyright © 2007 - 2015 Tangible Software Solutions Inc.
-// This class can be used by anyone provided that the copyright notice remains intact.
-//
-// This class provides the logic to simulate Java rectangular arrays, which are jagged
-// arrays with inner arrays of the same length. A size of -1 indicates unknown length.
-//----------------------------------------------------------------------------------------
-internal static partial class RectangularArrays
-{
- internal static int[][] ReturnRectangularIntArray(int size1, int size2)
- {
- int[][] newArray;
- if (size1 > -1)
- {
- newArray = new int[size1][];
- if (size2 > -1)
- {
- for (int array1 = 0; array1 < size1; array1++)
- {
- newArray[array1] = new int[size2];
- }
- }
- }
- else
- newArray = null;
-
- return newArray;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/cs/StringHelperClass.cs
----------------------------------------------------------------------
diff --git a/cs/StringHelperClass.cs b/cs/StringHelperClass.cs
deleted file mode 100644
index 3bcece0..0000000
--- a/cs/StringHelperClass.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-//-------------------------------------------------------------------------------------------
-// Copyright © 2007 - 2015 Tangible Software Solutions Inc.
-// This class can be used by anyone provided that the copyright notice remains intact.
-//
-// This class is used to convert some aspects of the Java String class.
-//-------------------------------------------------------------------------------------------
-internal static class StringHelperClass
-{
- //----------------------------------------------------------------------------------
- // This method replaces the Java String.substring method when 'start' is a
- // method call or calculated value to ensure that 'start' is obtained just once.
- //----------------------------------------------------------------------------------
- internal static string SubstringSpecial(this string self, int start, int end)
- {
- return self.Substring(start, end - start);
- }
-
- //------------------------------------------------------------------------------------
- // This method is used to replace calls to the 2-arg Java String.startsWith method.
- //------------------------------------------------------------------------------------
- internal static bool StartsWith(this string self, string prefix, int toffset)
- {
- return self.IndexOf(prefix, toffset, System.StringComparison.Ordinal) == toffset;
- }
-
- //------------------------------------------------------------------------------
- // This method is used to replace most calls to the Java String.split method.
- //------------------------------------------------------------------------------
- internal static string[] Split(this string self, string regexDelimiter, bool trimTrailingEmptyStrings)
- {
- string[] splitArray = System.Text.RegularExpressions.Regex.Split(self, regexDelimiter);
-
- if (trimTrailingEmptyStrings)
- {
- if (splitArray.Length > 1)
- {
- for (int i = splitArray.Length; i > 0; i--)
- {
- if (splitArray[i - 1].Length > 0)
- {
- if (i < splitArray.Length)
- System.Array.Resize(ref splitArray, i);
-
- break;
- }
- }
- }
- }
-
- return splitArray;
- }
-
- //-----------------------------------------------------------------------------
- // These methods are used to replace calls to some Java String constructors.
- //-----------------------------------------------------------------------------
- internal static string NewString(sbyte[] bytes)
- {
- return NewString(bytes, 0, bytes.Length);
- }
- internal static string NewString(sbyte[] bytes, int index, int count)
- {
- return System.Text.Encoding.UTF8.GetString((byte[])(object)bytes, index, count);
- }
- internal static string NewString(sbyte[] bytes, string encoding)
- {
- return NewString(bytes, 0, bytes.Length, encoding);
- }
- internal static string NewString(sbyte[] bytes, int index, int count, string encoding)
- {
- return System.Text.Encoding.GetEncoding(encoding).GetString((byte[])(object)bytes, index, count);
- }
-
- //--------------------------------------------------------------------------------
- // These methods are used to replace calls to the Java String.getBytes methods.
- //--------------------------------------------------------------------------------
- internal static sbyte[] GetBytes(this string self)
- {
- return GetSBytesForEncoding(System.Text.Encoding.UTF8, self);
- }
- internal static sbyte[] GetBytes(this string self, string encoding)
- {
- return GetSBytesForEncoding(System.Text.Encoding.GetEncoding(encoding), self);
- }
- private static sbyte[] GetSBytesForEncoding(System.Text.Encoding encoding, string s)
- {
- sbyte[] sbytes = new sbyte[encoding.GetByteCount(s)];
- encoding.GetBytes(s, 0, s.Length, (byte[])(object)sbytes, 0);
- return sbytes;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/cs/TestECDH.cs
----------------------------------------------------------------------
diff --git a/cs/TestECDH.cs b/cs/TestECDH.cs
deleted file mode 100644
index 216414d..0000000
--- a/cs/TestECDH.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-using System;
-
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-/* test driver and function exerciser for ECDH/ECIES/ECDSA API Functions */
-
-public class TestECDH
-{
- public static void printBinary(sbyte[] array)
- {
- int i;
- for (i = 0;i < array.Length;i++)
- {
- Console.Write("{0:x2}", array[i]);
- }
- Console.WriteLine();
- }
-
- public static void Main(string[] args)
- {
- int i , j = 0, res ;
- int result;
- string pp = "M0ng00se";
-
- int EGS = ECDH.EGS;
- int EFS = ECDH.EFS;
- int EAS = AES.KS;
-
- sbyte[] S1 = new sbyte[EGS];
- sbyte[] W0 = new sbyte[2 * EFS + 1];
- sbyte[] W1 = new sbyte[2 * EFS + 1];
- sbyte[] Z0 = new sbyte[EFS];
- sbyte[] Z1 = new sbyte[EFS];
- sbyte[] RAW = new sbyte[100];
- sbyte[] SALT = new sbyte[8];
- sbyte[] P1 = new sbyte[3];
- sbyte[] P2 = new sbyte[4];
- sbyte[] V = new sbyte[2 * EFS + 1];
- sbyte[] M = new sbyte[17];
- sbyte[] T = new sbyte[12];
- sbyte[] CS = new sbyte[EGS];
- sbyte[] DS = new sbyte[EGS];
-
- RAND rng = new RAND();
-
- rng.clean();
- for (i = 0;i < 100;i++)
- {
- RAW[i] = (sbyte)(i);
- }
-
- rng.seed(100,RAW);
-
-//for (j=0;j<100;j++)
-//{
-
- for (i = 0;i < 8;i++)
- {
- SALT[i] = (sbyte)(i + 1); // set Salt
- }
-
- Console.WriteLine("Alice's Passphrase= " + pp);
- sbyte[] PW = pp.GetBytes();
-
-/* private key S0 of size EGS bytes derived from Password and Salt */
-
- sbyte[] S0 = ECDH.PBKDF2(PW,SALT,1000,EGS);
-
- Console.Write("Alice's private key= 0x");
- printBinary(S0);
-
-/* Generate Key pair S/W */
- ECDH.KEY_PAIR_GENERATE(null,S0,W0);
-
- Console.Write("Alice's public key= 0x");
- printBinary(W0);
-
- res = ECDH.PUBLIC_KEY_VALIDATE(true,W0);
- if (res != 0)
- {
- Console.WriteLine("ECP Public Key is invalid!\n");
- return;
- }
-/* Random private key for other party */
- ECDH.KEY_PAIR_GENERATE(rng,S1,W1);
-
- Console.Write("Servers private key= 0x");
- printBinary(S1);
-
- Console.Write("Servers public key= 0x");
- printBinary(W1);
-
-
- res = ECDH.PUBLIC_KEY_VALIDATE(true,W1);
- if (res != 0)
- {
- Console.Write("ECP Public Key is invalid!\n");
- return;
- }
-
-/* Calculate common key using DH - IEEE 1363 method */
-
- ECDH.ECPSVDP_DH(S0,W1,Z0);
- ECDH.ECPSVDP_DH(S1,W0,Z1);
-
- bool same = true;
- for (i = 0;i < EFS;i++)
- {
- if (Z0[i] != Z1[i])
- {
- same = false;
- }
- }
-
- if (!same)
- {
- Console.WriteLine("*** ECPSVDP-DH Failed");
- return;
- }
-
- sbyte[] KEY = ECDH.KDF1(Z0,EAS);
-
- Console.Write("Alice's DH Key= 0x");
- printBinary(KEY);
- Console.Write("Servers DH Key= 0x");
- printBinary(KEY);
-
- Console.WriteLine("Testing ECIES");
-
- P1[0] = 0x0;
- P1[1] = 0x1;
- P1[2] = 0x2;
- P2[0] = 0x0;
- P2[1] = 0x1;
- P2[2] = 0x2;
- P2[3] = 0x3;
-
- for (i = 0;i <= 16;i++)
- {
- M[i] = (sbyte)i;
- }
-
- sbyte[] C = ECDH.ECIES_ENCRYPT(P1,P2,rng,W1,M,V,T);
-
- Console.WriteLine("Ciphertext= ");
- Console.Write("V= 0x");
- printBinary(V);
- Console.Write("C= 0x");
- printBinary(C);
- Console.Write("T= 0x");
- printBinary(T);
-
-
- M = ECDH.ECIES_DECRYPT(P1,P2,V,C,T,S1);
- if (M.Length == 0)
- {
- Console.WriteLine("*** ECIES Decryption Failed\n");
- return;
- }
- else
- {
- Console.WriteLine("Decryption succeeded");
- }
-
- Console.Write("Message is 0x");
- printBinary(M);
-
- Console.WriteLine("Testing ECDSA");
-
- if (ECDH.ECPSP_DSA(rng,S0,M,CS,DS) != 0)
- {
- Console.WriteLine("***ECDSA Signature Failed");
- return;
- }
- Console.WriteLine("Signature= ");
- Console.Write("C= 0x");
- printBinary(CS);
- Console.Write("D= 0x");
- printBinary(DS);
-
- if (ECDH.ECPVP_DSA(W0,M,CS,DS) != 0)
- {
- Console.WriteLine("***ECDSA Verification Failed");
- return;
- }
- else
- {
- Console.WriteLine("ECDSA Signature/Verification succeeded " + j);
- }
-//}
-//System.out.println("Test Completed Successfully");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/cs/TestECM.cs
----------------------------------------------------------------------
diff --git a/cs/TestECM.cs b/cs/TestECM.cs
deleted file mode 100644
index d9c1eeb..0000000
--- a/cs/TestECM.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using System;
-
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-/* test driver and function exerciser for ECDH API Function only - for use with Montgomery curves */
-
-public class TestECM
-{
- public static void printBinary(sbyte[] array)
- {
- int i;
- for (i = 0;i < array.Length;i++)
- {
- Console.Write("{0:x2}", array[i]);
- }
- Console.WriteLine();
- }
-
- public static void Main(string[] args)
- {
- int i , j = 0, res ;
- int result;
- string pp = "M0ng00se";
-
- int EGS = ECDH.EGS;
- int EFS = ECDH.EFS;
- int EAS = AES.KS;
-
- sbyte[] S1 = new sbyte[EGS];
- sbyte[] W0 = new sbyte[2 * EFS + 1];
- sbyte[] W1 = new sbyte[2 * EFS + 1];
- sbyte[] Z0 = new sbyte[EFS];
- sbyte[] Z1 = new sbyte[EFS];
- sbyte[] RAW = new sbyte[100];
- sbyte[] SALT = new sbyte[8];
-
- RAND rng = new RAND();
-
- rng.clean();
- for (i = 0;i < 100;i++)
- {
- RAW[i] = (sbyte)(i);
- }
-
- rng.seed(100,RAW);
-
-//for (j=0;j<100;j++)
-//{
-
- for (i = 0;i < 8;i++)
- {
- SALT[i] = (sbyte)(i + 1); // set Salt
- }
-
- Console.WriteLine("Alice's Passphrase= " + pp);
- sbyte[] PW = pp.GetBytes();
-
-/* private key S0 of size EGS bytes derived from Password and Salt */
-
- sbyte[] S0 = ECDH.PBKDF2(PW,SALT,1000,EGS);
-
- Console.Write("Alice's private key= 0x");
- printBinary(S0);
-
-/* Generate Key pair S/W */
- ECDH.KEY_PAIR_GENERATE(null,S0,W0);
-
- Console.Write("Alice's public key= 0x");
- printBinary(W0);
-
- res = ECDH.PUBLIC_KEY_VALIDATE(true,W0);
- if (res != 0)
- {
- Console.WriteLine("Alice's public Key is invalid!\n");
- return;
- }
-/* Random private key for other party */
- ECDH.KEY_PAIR_GENERATE(rng,S1,W1);
-
- Console.Write("Servers private key= 0x");
- printBinary(S1);
-
- Console.Write("Servers public key= 0x");
- printBinary(W1);
-
-
- res = ECDH.PUBLIC_KEY_VALIDATE(true,W1);
- if (res != 0)
- {
- Console.Write("Server's public Key is invalid!\n");
- return;
- }
-
-/* Calculate common key using DH - IEEE 1363 method */
-
- ECDH.ECPSVDP_DH(S0,W1,Z0);
- ECDH.ECPSVDP_DH(S1,W0,Z1);
-
- bool same = true;
- for (i = 0;i < EFS;i++)
- {
- if (Z0[i] != Z1[i])
- {
- same = false;
- }
- }
-
- if (!same)
- {
- Console.WriteLine("*** ECPSVDP-DH Failed");
- return;
- }
-
- sbyte[] KEY = ECDH.KDF1(Z0,EAS);
-
- Console.Write("Alice's DH Key= 0x");
- printBinary(KEY);
- Console.Write("Servers DH Key= 0x");
- printBinary(KEY);
-
-//}
-//System.out.println("Test Completed Successfully");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/cs/TestMPIN.cs
----------------------------------------------------------------------
diff --git a/cs/TestMPIN.cs b/cs/TestMPIN.cs
deleted file mode 100644
index e3eeb83..0000000
--- a/cs/TestMPIN.cs
+++ /dev/null
@@ -1,298 +0,0 @@
-using System;
-
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-/* test driver and function exerciser for MPIN API Functions */
-
-
-public class TestMPIN
-{
- internal static bool PERMITS = true;
- internal static bool PINERROR = true;
- internal static bool FULL = true;
- internal static bool SINGLE_PASS = false;
-
- internal static void printBinary(sbyte[] array)
- {
- int i;
- for (i = 0;i < array.Length;i++)
- {
- Console.Write("{0:x2}", array[i]);
- }
- Console.WriteLine();
- }
-
- public static void Main(string[] args)
- {
- RAND rng = new RAND();
- sbyte[] raw = new sbyte[100];
- for (int i = 0;i < 100;i++)
- {
- raw[i] = (sbyte)(i + 1);
- }
- rng.seed(100,raw);
-
- int EGS = MPIN.EGS;
- int EFS = MPIN.EFS;
- int G1S = 2 * EFS + 1; // Group 1 Size
- int G2S = 4 * EFS; // Group 2 Size
- int EAS = 16;
-
- sbyte[] S = new sbyte[EGS];
- sbyte[] SST = new sbyte[G2S];
- sbyte[] TOKEN = new sbyte[G1S];
- sbyte[] PERMIT = new sbyte[G1S];
- sbyte[] SEC = new sbyte[G1S];
- sbyte[] xID = new sbyte[G1S];
- sbyte[] xCID = new sbyte[G1S];
- sbyte[] X = new sbyte[EGS];
- sbyte[] Y = new sbyte[EGS];
- sbyte[] E = new sbyte[12 * EFS];
- sbyte[] F = new sbyte[12 * EFS];
- sbyte[] HID = new sbyte[G1S];
- sbyte[] HTID = new sbyte[G1S];
-
- sbyte[] G1 = new sbyte[12 * EFS];
- sbyte[] G2 = new sbyte[12 * EFS];
- sbyte[] R = new sbyte[EGS];
- sbyte[] Z = new sbyte[G1S];
- sbyte[] W = new sbyte[EGS];
- sbyte[] T = new sbyte[G1S];
- sbyte[] CK = new sbyte[EAS];
- sbyte[] SK = new sbyte[EAS];
-
-/* Trusted Authority set-up */
-
- MPIN.RANDOM_GENERATE(rng,S);
- Console.Write("Master Secret s: 0x");
- printBinary(S);
-
- /* Create Client Identity */
- string IDstr = "testUser@miracl.com";
- sbyte[] CLIENT_ID = IDstr.GetBytes();
-
- sbyte[] HCID = MPIN.HASH_ID(CLIENT_ID); // Either Client or TA calculates Hash(ID) - you decide!
-
- Console.Write("Client ID= ");
- printBinary(CLIENT_ID);
-
-/* Client and Server are issued secrets by DTA */
- MPIN.GET_SERVER_SECRET(S,SST);
- Console.Write("Server Secret SS: 0x");
- printBinary(SST);
-
- MPIN.GET_CLIENT_SECRET(S,HCID,TOKEN);
- Console.Write("Client Secret CS: 0x");
- printBinary(TOKEN);
-
-/* Client extracts PIN from secret to create Token */
- int pin = 1234;
- Console.WriteLine("Client extracts PIN= " + pin);
- int rtn = MPIN.EXTRACT_PIN(CLIENT_ID,pin,TOKEN);
- if (rtn != 0)
- {
- Console.WriteLine("FAILURE: EXTRACT_PIN rtn: " + rtn);
- }
-
- Console.Write("Client Token TK: 0x");
- printBinary(TOKEN);
-
- if (FULL)
- {
- MPIN.PRECOMPUTE(TOKEN,HCID,G1,G2);
- }
- int date;
- if (PERMITS)
- {
- date = MPIN.today();
- Console.WriteLine("Date= "+date);
-/* Client gets "Time Token" permit from DTA */
- MPIN.GET_CLIENT_PERMIT(date,S,HCID,PERMIT);
- Console.Write("Time Permit TP: 0x");
- printBinary(PERMIT);
-
-/* This encoding makes Time permit look random - Elligator squared */
- MPIN.ENCODING(rng,PERMIT);
- Console.Write("Encoded Time Permit TP: 0x");
- printBinary(PERMIT);
- MPIN.DECODING(PERMIT);
- Console.Write("Decoded Time Permit TP: 0x");
- printBinary(PERMIT);
- }
- else
- {
- date = 0;
- }
-
- Console.Write("\nPIN= ");
-// Scanner scan = new Scanner(System.in);
-// pin = scan.Next();
-
- pin=int.Parse(Console.ReadLine());
-
-/* Set date=0 and PERMIT=null if time permits not in use
-
-Client First pass: Inputs CLIENT_ID, optional RNG, pin, TOKEN and PERMIT. Output xID =x .H(CLIENT_ID) and re-combined secret SEC
-If PERMITS are is use, then date!=0 and PERMIT is added to secret and xCID = x.(H(CLIENT_ID)+H(date|H(CLIENT_ID)))
-Random value x is supplied externally if RNG=null, otherwise generated and passed out by RNG
-
-IMPORTANT: To save space and time..
-If Time Permits OFF set xCID = null, HTID=null and use xID and HID only
-If Time permits are ON, AND pin error detection is required then all of xID, xCID, HID and HTID are required
-If Time permits are ON, AND pin error detection is NOT required, set xID=null, HID=null and use xCID and HTID only.
-
-
-*/
-
- sbyte[] pxID = xID;
- sbyte[] pxCID = xCID;
- sbyte[] pHID = HID;
- sbyte[] pHTID = HTID;
- sbyte[] pE = E;
- sbyte[] pF = F;
- sbyte[] pPERMIT = PERMIT;
- sbyte[] prHID;
-
- if (date != 0)
- {
-
- prHID = pHTID;
- if (!PINERROR)
- {
- pxID = null;
- pHID = null;
- }
- }
- else
- {
- prHID = pHID;
- pPERMIT = null;
- pxCID = null;
- pHTID = null;
- }
- if (!PINERROR)
- {
- pE = null;
- pF = null;
- }
-
- if (SINGLE_PASS)
- {
- Console.WriteLine("MPIN Single Pass");
- int timeValue = MPIN.GET_TIME();
- rtn = MPIN.CLIENT(date,CLIENT_ID,rng,X,pin,TOKEN,SEC,pxID,pxCID,pPERMIT,timeValue,Y);
- if (rtn != 0)
- {
- Console.WriteLine("FAILURE: CLIENT rtn: " + rtn);
- }
-
- if (FULL)
- {
- HCID = MPIN.HASH_ID(CLIENT_ID);
- MPIN.GET_G1_MULTIPLE(rng,1,R,HCID,Z); // Also Send Z=r.ID to Server, remember random r
- }
-
- rtn = MPIN.SERVER(date,pHID,pHTID,Y,SST,pxID,pxCID,SEC,pE,pF,CLIENT_ID,timeValue);
- if (rtn != 0)
- {
- Console.WriteLine("FAILURE: SERVER rtn: " + rtn);
- }
-
- if (FULL)
- {
- MPIN.GET_G1_MULTIPLE(rng,0,W,prHID,T); // Also send T=w.ID to client, remember random w
- }
- }
- else
- {
- Console.WriteLine("MPIN Multi Pass");
- /* Send U=x.ID to server, and recreate secret from token and pin */
- rtn = MPIN.CLIENT_1(date,CLIENT_ID,rng,X,pin,TOKEN,SEC,pxID,pxCID,pPERMIT);
- if (rtn != 0)
- {
- Console.WriteLine("FAILURE: CLIENT_1 rtn: " + rtn);
- }
-
- if (FULL)
- {
- HCID = MPIN.HASH_ID(CLIENT_ID);
- MPIN.GET_G1_MULTIPLE(rng,1,R,HCID,Z); // Also Send Z=r.ID to Server, remember random r
- }
-
- /* Server calculates H(ID) and H(T|H(ID)) (if time permits enabled), and maps them to points on the curve HID and HTID resp. */
- MPIN.SERVER_1(date,CLIENT_ID,pHID,pHTID);
-
- /* Server generates Random number Y and sends it to Client */
- MPIN.RANDOM_GENERATE(rng,Y);
-
- if (FULL)
- {
- MPIN.GET_G1_MULTIPLE(rng,0,W,prHID,T); // Also send T=w.ID to client, remember random w
- }
-
- /* Client Second Pass: Inputs Client secret SEC, x and y. Outputs -(x+y)*SEC */
- rtn = MPIN.CLIENT_2(X,Y,SEC);
- if (rtn != 0)
- {
- Console.WriteLine("FAILURE: CLIENT_2 rtn: " + rtn);
- }
-
- /* Server Second pass. Inputs hashed client id, random Y, -(x+y)*SEC, xID and xCID and Server secret SST. E and F help kangaroos to find error. */
- /* If PIN error not required, set E and F = null */
-
- rtn = MPIN.SERVER_2(date,pHID,pHTID,Y,SST,pxID,pxCID,SEC,pE,pF);
-
- if (rtn != 0)
- {
- Console.WriteLine("FAILURE: SERVER_1 rtn: " + rtn);
- }
- }
-
- if (rtn == MPIN.BAD_PIN)
- {
- Console.WriteLine("Server says - Bad Pin. I don't know you. Feck off.\n");
- if (PINERROR)
- {
- int err = MPIN.KANGAROO(E,F);
- if (err != 0)
- {
- Console.Write("(Client PIN is out by {0:D})\n",err);
- }
- }
- return;
- }
- else
- {
- Console.WriteLine("Server says - PIN is good! You really are " + IDstr);
- }
-
-
- if (FULL)
- {
- MPIN.CLIENT_KEY(G1,G2,pin,R,X,T,CK);
- Console.Write("Client Key = 0x");
- printBinary(CK);
-
- MPIN.SERVER_KEY(Z,SST,W,pxID,pxCID,SK);
- Console.Write("Server Key = 0x");
- printBinary(SK);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/cs/TestRSA.cs
----------------------------------------------------------------------
diff --git a/cs/TestRSA.cs b/cs/TestRSA.cs
deleted file mode 100644
index 07cd6f9..0000000
--- a/cs/TestRSA.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using System;
-
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-/* test driver and function exerciser for RSA API Functions */
-
-public class TestRSA
-{
-
- public static void Main(string[] args)
- {
- int i;
- int RFS = RSA.RFS;
-
- string message = "Hello World\n";
-
- rsa_public_key pub = new rsa_public_key(ROM.FFLEN);
- rsa_private_key priv = new rsa_private_key(ROM.HFLEN);
-
- sbyte[] ML = new sbyte[RFS];
- sbyte[] C = new sbyte[RFS];
- sbyte[] RAW = new sbyte[100];
-
- RAND rng = new RAND();
-
- rng.clean();
- for (i = 0;i < 100;i++)
- {
- RAW[i] = (sbyte)(i);
- }
-
- rng.seed(100,RAW);
-//for (i=0;i<10;i++)
-//{
- Console.WriteLine("Generating public/private key pair");
- RSA.KEY_PAIR(rng,65537,priv,pub);
-
- sbyte[] M = message.GetBytes();
- Console.Write("Encrypting test string\n");
- sbyte[] E = RSA.OAEP_ENCODE(M,rng,null); // OAEP encode message M to E
-
- RSA.ENCRYPT(pub,E,C); // encrypt encoded message
- Console.Write("Ciphertext= 0x");
- RSA.printBinary(C);
-
- Console.Write("Decrypting test string\n");
- RSA.DECRYPT(priv,C,ML);
- sbyte[] MS = RSA.OAEP_DECODE(null,ML); // OAEP decode message
-
- message = StringHelperClass.NewString(MS);
- Console.Write(message);
-//}
- RSA.PRIVATE_KEY_KILL(priv);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/cs/readme.txt
----------------------------------------------------------------------
diff --git a/cs/readme.txt b/cs/readme.txt
deleted file mode 100644
index 14b81d0..0000000
--- a/cs/readme.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-AMCL is very simple to build for C#.
-
-NOTE: The C# code was automatically generated from the Java64 code using
-the Java to C# Converter from Tangible Software Solutions. A few minor
-fix-ups were required.
-
-First - decide the modulus and curve type you want to use. Edit ROM.cs
-where indicated. You will probably want to use one of the curves whose
-details are already in there.
-
-Three example API files are provided, MPIN.cs which
-supports our M-Pin (tm) protocol, ECDH.cs which supports elliptic
-curve key exchange, digital signature and public key crypto, and RSA.cs
-which supports the RSA method.
-
-In the ROM.cs file you must provide the curve constants. Several examples
-are provided there, if you are willing to use one of these.
-
-For a quick jumpstart:-
-
-csc TestMPIN.cs MPIN.cs FP.cs BIG.cs DBIG.cs AES.cs HASH.cs RAND.cs ROM.cs StringHelperClass.cs ECP.cs FP2.cs ECP2.cs FP4.cs FP12.cs PAIR.cs RectangularArrays.cs
-
-or
-
-csc TestECDH.cs ECDH.cs FP.cs BIG.cs DBIG.cs AES.cs HASH.cs RAND.cs ROM.cs StringHelperClass.cs ECP.cs
-
-or
-
-csc TestRSA.cs RSA.cs FF.cs BIG.cs DBIG.cs HASH.cs RAND.cs ROM.cs StringHelperClass.cs
-
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/data/icon.bmp
----------------------------------------------------------------------
diff --git a/data/icon.bmp b/data/icon.bmp
deleted file mode 100644
index 3e53971..0000000
Binary files a/data/icon.bmp and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/data/icon.ico
----------------------------------------------------------------------
diff --git a/data/icon.ico b/data/icon.ico
deleted file mode 100644
index 89dfae6..0000000
Binary files a/data/icon.ico and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/docs/AMCL.dox
----------------------------------------------------------------------
diff --git a/docs/AMCL.dox b/docs/AMCL.dox
deleted file mode 100755
index 68f1fa8..0000000
--- a/docs/AMCL.dox
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- This file contains NO source code, just some documentation for doxygen to
- parse.
-*/
-
-/*!
- \mainpage Apache Milagro Crypto Library (AMCL)
-
- Read <a href="AMCL.pdf">AMCL.pdf</a> for an introduction to AMCL
-
- AMCL is provided in these languages;
-
-<ul type="disc">
- <li> C
- <li> JAVA
- <li> JavaScript
- <li> C#
- <li> Swift
- <li> GO
-</ul>
-
- There is also a Python wrapper provided that requires <a href="https://cffi.readthedocs.org/en/release-0.8/">CFFI</a>
-
- \section homepage Project page
- The official project page is hosted at
- <a href="http://www.miracl.com/index">MIRACL Products</a>
-
- \section license License
-
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-
- \section platforms Platforms
-
- The software can be compiled and installed for these operating systems;
-
-<ul type="disc">
- <li>Linux</li>
- <li>Windows</li>
- <li>Mac OS</li>
-</ul>
-
-
-
- \section downloads Downloads
-
- The source code is available from the GIT repository:
-
- git clone https://github.com/miracl/milagro-crypto
-
- \section installonmainpage Installation
-
- There are instructions for building for \ref linux, \ref mac and \ref windows.
-
-*/
-
-
-/*!
- \page linux Linux
-
-<h2>Software dependencies</h2>
-
-CMake is required to build the library and can usually be installed from
-the operating system package manager.
-
-<ul type="disc">
- <li>sudo apt-get install cmake</li>
-</ul>
-
-If not, then you can download it from www.cmake.org
-
-The C Foreign Function Interface for Python <a href="https://cffi.readthedocs.org/en/latest/">CFFI</a> module
-is also required if you wish to use the Python module.
-
-<ul type="disc">
- <li>sudo pip install cffi</li>
-</ul>
-
-In order to build the documentation <a href="http://www.stack.nl/~dimitri/doxygen/">doxygen</a> is required.
-
-<h2>Build Instructions</h2>
-
-<p>The default build is for 32 bit machines</p>
-
-<ol type="disc">
- <li>mkdir Release</li>
- <li>cd Release</li>
- <li>cmake ..</li>
- <li>make</li>
- <li>make test</li>
- <li>make doc</li>
- <li>sudo make install</li>
-</ol>
-
-<p>The build can be configured using by setting flags on the command line i.e.</p>
-
-<ol type="disc">
- <li>cmake -D CMAKE_INSTALL_PREFIX=/opt/amcl -D WORD_LENGTH=64 ..</li>
-</ol>
-
-<h2>Uninstall software</h2>
-
-<ul type="disc">
- <li>sudo make uninstall</li>
-</ul>
-
-<h2>Building an installer</h2>
-
-<p>After having built the libraries you can build a binary installer and a source distribution by running this command</p>
-
-<ul type="disc">
- <li>make package</li>
-</ul>
-
-*/
-
-
-
-
-/*!
- \page mac Mac OS
-
-<h2>Software dependencies</h2>
-
-Install <a href="http://brew.sh/">Homebrew</a>
-
-<ul type="disc">
- <li>ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"</li>
-</ul>
-
-Install <a href="http://www.cmake.org/download/">cmake</a>
-
-<ul type="disc">
- <li>brew install cmake</li>
-</ul>
-
-The C Foreign Function Interface for Python <a href="https://cffi.readthedocs.org/en/latest/">CFFI</a> module
-is also required if you wish to use the Python module.
-
-<ul type="disc">
- <li>brew install pkg-config libffi</li>
- <li>sudo pip install cffi</li>
-</ul>
-
-In order to build the documentation <a href="http://www.stack.nl/~dimitri/doxygen/">doxygen</a> is required.
-
-<ul type="disc">
- <li>brew install doxygen</li>
-</ul>
-
-<h2>Build Instructions</h2>
-
-<p>The default build is for 32 bit machines</p>
-
-<ol type="disc">
- <li>mkdir Release</li>
- <li>cd Release</li>
- <li>cmake ..</li>
- <li>make</li>
- <li>make test</li>
- <li>make doc</li>
- <li>sudo make install</li>
-</ol>
-
-<p>The build can be configured using by setting flags on the command line i.e.</p>
-
-<ol type="disc">
- <li>cmake -DWORD_LENGTH=64 ..</li>
-</ol>
-
-<h2>Uninstall software</h2>
-
-<ul type="disc">
- <li>sudo make uninstall</li>
-</ul>
-
-*/
-
-/*!
- \page windows Windows
-
-<h2>Software dependencies</h2>
-
-<p>Minimalist GNU for Windows <a href="http://www.mingw.org/">MinGW</a> provides the
-tool set used to build the library and should be installed. When the MinGW installer
-starts select the mingw32-base and mingw32-gcc-g++ components. From the menu select
-"Installation" -> "Apply Changes", then click "Apply". Finally add C:\\MinGW\\bin
-to the PATH variable.</p>
-
-<p>CMake is required to build the library and can be downloaded from www.cmake.org</p>
-
-<p>The C Foreign Function Interface for Python <a href="https://cffi.readthedocs.org/en/latest/">CFFI</a> module
-is also required, if you wish to use the Python module.</p>
-
-<ul type="disc">
- <li>pip install cffi</li>
-</ul>
-
-In order to build the documentation <a href="http://www.stack.nl/~dimitri/doxygen/">doxygen</a> is required.
-
-<h2>Build Instructions</h2>
-
-<p>Start a command prompt as an administrator</p>
-
-<p>The default build is for 32 bit machines</p>
-
-<ol type="disc">
- <li>mkdir Release</li>
- <li>cd Release</li>
- <li>cmake -G "MinGW Makefiles" ..</li>
- <li>mingw32-make</li>
- <li>mingw32-make test</li>
- <li>mingw32-make doc</li>
- <li>mingw32-make install</li>
-</ol>
-
-<p>
-
-Post install append the PATH system variable to point to the install ./lib.
-
-My Computer -> Properties -> Advanced > Environment Variables
-
-</p>
-
-
-<p>The build can be configured using by setting flags on the command line i.e.</p>
-
-<ol type="disc">
- <li>cmake -G "MinGW Makefiles" -DWORD_LENGTH=64 ..</li>
-</ol>
-
-<h2>Uninstall software</h2>
-
-<ul type="disc">
- <li>mingw32-make uninstall</li>
-</ul>
-
-<h2>Building an installer</h2>
-
-<p>After having built the libraries you can build a Windows installer using this command</p>
-
-<ul type="disc">
- <li>sudo mingw32-make package</li>
-</ul>
-
-<p>In order for this to work <a href="http://nsis.sourceforge.net/Download">NSSI</a> has
-to have been installed</p>
-
-*/
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/70e3a3a3/docs/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
deleted file mode 100644
index 55efd99..0000000
--- a/docs/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
-
-add_custom_target(doc
-${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
-WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-COMMENT "Generating documentation with Doxygen" VERBATIM)
-
-file(COPY ${PROJECT_SOURCE_DIR}/AMCL.pdf DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/html/")
-
-
-