Пример #1
0
        public void GenerateMiniLockKeyPairTest()
        {
            const string expected = "Cz5bEJLKdSib9kWxkmskExaaLdRg8tVA2qsFBnfdQwkMe";
            const string email    = "*****@*****.**";
            const string password = "******";

            Console.WriteLine("--- Generate miniLock KeyPair start ---");
            var zx = new Zxcvbn.Zxcvbn();

            Console.WriteLine(" - E-Mail (utf8): " + email + " [" + email.Length + "]");
            Console.WriteLine(" - E-Mail Entropy (~): " + zx.EvaluatePassword(email).Entropy);
            Console.WriteLine(" - Password (utf8): " + password + " [" + password.Length + "]");
            Console.WriteLine(" - Password Entropy (~): " + zx.EvaluatePassword(password).Entropy);
            var keyPair = KeyGenerator.GenerateMiniLockKeyPair(email, password);

            Console.WriteLine(" - Private Key (hex): " + Utilities.BinaryToHex(keyPair.PrivateKey) + " [" +
                              keyPair.PrivateKey.Length + "]");
            Console.WriteLine(" - Public Key (hex): " + Utilities.BinaryToHex(keyPair.PublicKey) + " [" +
                              keyPair.PublicKey.Length + "]");
            var encodedPublicKey = KeyGenerator.EncodeMiniLockPublicKey(keyPair.PublicKey);

            Console.WriteLine(" - Public ID (base58): " + encodedPublicKey + " [" +
                              encodedPublicKey.Length + "]");
            Console.WriteLine("--- Generate miniLock KeyPair end ---");
            Assert.AreEqual(expected, encodedPublicKey);
        }
Пример #2
0
        public void DecodeCurveLockIdTest()
        {
            const string expected  = "fc97747205619f7a7c6e5b6c9179d38a87f33bf3c350c8c1ce06df26999df256";
            var          publicKey = KeyGenerator.DecodeCurveLockPublicKey("NMgsvm7ytEHdGEuj9QEaoW7uH2tMQe9Ji2h9viw7kzFkgApVkH");

            Assert.AreEqual(expected, Utilities.BinaryToHex(publicKey));
        }
Пример #3
0
        public void GenerateCurveLockKeyPairTest()
        {
            const string expected = "MrDDGk7GYEypr93LMgJn4Av3c98fWamRKvAKbjrTEvjtz5kRxj";
            const string email    = "*****@*****.**";
            const string password = "******";

            Console.WriteLine("--- Generate CurveLock KeyPair start ---");
            var zx = new Zxcvbn.Zxcvbn();

            Console.WriteLine(" - E-Mail (utf8): " + email + " [" + email.Length + "]");
            Console.WriteLine(" - E-Mail Entropy (~): " + zx.EvaluatePassword(email).Entropy);
            Console.WriteLine(" - Password (utf8): " + password + " [" + password.Length + "]");
            Console.WriteLine(" - Password Entropy (~): " + zx.EvaluatePassword(password).Entropy);
            var keyPair = KeyGenerator.GenerateCurveLockKeyPair(email, password);

            Console.WriteLine(" - Private Key (hex): " + Utilities.BinaryToHex(keyPair.PrivateKey) + " [" +
                              keyPair.PrivateKey.Length + "]");
            Console.WriteLine(" - Public Key (hex): " + Utilities.BinaryToHex(keyPair.PublicKey) + " [" +
                              keyPair.PublicKey.Length + "]");
            var encodedPublicKey = KeyGenerator.EncodeCurveLockPublicKey(keyPair.PublicKey);

            Console.WriteLine(" - Public ID (base58): " + encodedPublicKey + " [" +
                              encodedPublicKey.Length + "]");
            Console.WriteLine("--- Generate CurveLock KeyPair end ---");
            Assert.AreEqual(expected, encodedPublicKey);
        }
Пример #4
0
        public void DecodeBytejailIdTest()
        {
            const string expected  = "91e9b97edba152f97997cc7a4c5ad9c98558645b3a455f214f0202dccaa93229";
            var          publicKey = KeyGenerator.DecodeBytejailPublicKey("2PonPHk28TBvBu3iADjXZAH5gPh8fTpQ2mh4eMbkLhPnMoc5Vwq");

            Assert.AreEqual(expected, Utilities.BinaryToHex(publicKey));
        }
Пример #5
0
        public void PublicKeyAuthConvertToCurve25519()
        {
            var keypairSeed = new byte[] {
                0x42, 0x11, 0x51, 0xa4, 0x59, 0xfa, 0xea, 0xde,
                0x3d, 0x24, 0x71, 0x15, 0xf9, 0x4a, 0xed, 0xae,
                0x42, 0x31, 0x81, 0x24, 0x09, 0x5a, 0xfa, 0xbe,
                0x4d, 0x14, 0x51, 0xa5, 0x59, 0xfa, 0xed, 0xee
            };

            var keys = PublicKeyAuth.GenerateKeyPair(keypairSeed);

            var ed25519Pk   = keys.PublicKey;
            var ed25519SkPk = keys.PrivateKey;

            var curve25519Pk = PublicKeyAuth.ConvertEd25519PublicKeyToCurve25519PublicKey(ed25519Pk);
            var curve25519Sk = PublicKeyAuth.ConvertEd25519SecretKeyToCurve25519SecretKey(ed25519SkPk);

            Assert.AreEqual(Utilities.BinaryToHex(curve25519Pk, Utilities.HexFormat.None, Utilities.HexCase.Upper),
                            "F1814F0E8FF1043D8A44D25BABFF3CEDCAE6C22C3EDAA48F857AE70DE2BAAE50");
            Assert.AreEqual(Utilities.BinaryToHex(curve25519Sk, Utilities.HexFormat.None, Utilities.HexCase.Upper),
                            "8052030376D47112BE7F73ED7A019293DD12AD910B654455798B4667D73DE166");

            for (var i = 0; i < 500; i++)
            {
                keys         = PublicKeyAuth.GenerateKeyPair();
                ed25519Pk    = keys.PublicKey;
                ed25519SkPk  = keys.PrivateKey;
                curve25519Pk = PublicKeyAuth.ConvertEd25519PublicKeyToCurve25519PublicKey(ed25519Pk);
                curve25519Sk = PublicKeyAuth.ConvertEd25519SecretKeyToCurve25519SecretKey(ed25519SkPk);
                var curve25519Pk2 = ScalarMult.Base(curve25519Sk);

                CollectionAssert.AreEqual(curve25519Pk, curve25519Pk2);
            }
        }
Пример #6
0
        public void GenerateBytejailKeyPairTest()
        {
            const string expected         = "2PNPvrfYAQxhaGYaAzsWTYgEzymmQZ37jG2vJThBJHDcY4SABnH";
            const string userInputPartOne = "*****@*****.**";
            const string userInputPartTwo = "magnetometers payee induce tangibly polonaises unrestricted oilfield";

            Console.WriteLine("--- Generate bytejail KeyPair start ---");
            var zx = new Zxcvbn.Zxcvbn();

            Console.WriteLine(" - UserInputPartOne (utf8): " + userInputPartOne + " [" + userInputPartOne.Length + "]");
            Console.WriteLine(" - UserInputPartOne Entropy (~): " + zx.EvaluatePassword(userInputPartOne).Entropy);
            Console.WriteLine(" - UserInputPartTwo (utf8): " + userInputPartTwo + " [" + userInputPartTwo.Length + "]");
            Console.WriteLine(" - UserInputPartTwo Entropy (~): " + zx.EvaluatePassword(userInputPartTwo).Entropy);
            var keyPair = KeyGenerator.GenerateBytejailKeyPair(userInputPartOne, userInputPartTwo);

            Console.WriteLine(" - Private Key (hex): " + Utilities.BinaryToHex(keyPair.PrivateKey) + " [" +
                              keyPair.PrivateKey.Length + "]");
            Console.WriteLine(" - Public Key (hex): " + Utilities.BinaryToHex(keyPair.PublicKey) + " [" +
                              keyPair.PublicKey.Length + "]");
            var encodedPublicKey = KeyGenerator.EncodeBytejailPublicKey(keyPair.PublicKey);

            Console.WriteLine(" - Public ID (base58): " + encodedPublicKey + " [" +
                              encodedPublicKey.Length + "]");
            Console.WriteLine("--- Generate bytejail KeyPair end ---");
            Assert.AreEqual(expected, encodedPublicKey);
        }
Пример #7
0
        public void GenerateBytejailKeyPairExaggeratedTest()
        {
            const string expected = "2NjStPkM3Wr2JwqmH7gG7sRUhyGVG2FFewUajjbHrWRvjDtLqwB";
            // Test with KeePass generated inputs: length of 1024 exclude " and \
            const string userInputPartOne =
                "s7MgHRz?|dP@mmD7Q#Y~:m[]~Sjy7ad)t`tO&61B@o8l9p+['.V}y{L~])z{KM*:Cr8iw2t63^bpyn]b+x8Hh5#UG^gu>y1JgVj:4]NkYR<aE+T1C/3EaC9xxL#`n:=c0^_|eZm%-5T^yOM5DI9 ,XcG!Ej5=IuV0/j>bsYM'x[hQY#uwqNkm?0emxikBM$NHyzi9SLVd?E[)9x=.]d)f,]+9;;LJx|$ki|O-7PvZR/tF}9L&Hn!whdoklx+cyGiKCh=$qfXC9nuu;!21b=)as;R$%[d4[VESbTZ<tVMiZyT0|wDSCZTLT9v`QRg[6]m0Vgr]Ps@bp`J&P_4tfv:rJJ*P.z-!=]Nc07UwfUq2,C:vI1`LHrb$>ooM_S7{Lby/awngY9TMKAi[vj+V0u6'ot&gC?@6PtUP$8*iTeP`|~|)5^Y-_Nc@1]1jJO-.3+`r<BPFuDzah'H334*M^^8g;?v{9)P,=R[Uw*$D]w#oZm6yZ}c:5V^.*(F8S{?x!s#{)UL-}`VMdg:Y6Z]KE8%tjsE;Y)w+G>S@'K1Sf;]8<$`@Novad[whD.rahiJdfPetl`9 A)DH ZupA*6FIwU8n6Fa~Wf_-an*Etny9>GH}+5+F2!Y*?gD <P~`b~)xm~+9&2X;#K[iPj%F8.M/9/ifi?l1 )buY%2cIf,Rf/]NLgKoszB^ p$jmww1yfU)+lu#E-|)0lG7V{C!?]T`2cO/.k 3=C .`xcx&k sT1b&/.(8/Za)qO5w4)hDz'~tO]Y{ueGG[<<[L@kt1W~>Ct0ZsQNF{3RI!mIxS?L8CUTOEXxroeMhK;'p8xQ-_0Qr^St+0vJ;]#,?*0#F5146lN7MMQXN7b@Z)I>BQQ8S2'_WiBn)r$?Q~IE[)~b*`a8H8Y u`i4m# k^Z6%nk^.V_n5N?M.TS@?G=uE:%fpvhE8:)|Bm.fK.1w2|?Y}tpa)XuuhGt0DeWijlee2:8BqTNK2GDr!i2_M_?NnD2T{@G*Yc'gZ2Up(9}5]/NYd%^T$|0_";
            const string userInputPartTwo =
                ")DT~:*EnWSgY2])|aHjsEvBr#Xz$P);'b LEf23Qe}Q'8_('5X+AgMRsr?Xgl_j7X8|X&F},l&T cC3Z<$FXD.4H:q>xmr`8sR(T5=ub^`rcm#CgJo4Bt~krbpc{+RWtq-{ $)4pqd7fkDV>z+G3{@J=E;<Pn.|Sv5KA1~f5ir1FKMCh32~gULAn9DrT,uw4.-nDJmG&$W#~M'*Bx?^66ZGIyO@,(7M=otR;rxaJ!;W ;|?cVc?1K2lQvP[#zckA@}g$PC=AR>_KB~2gr*K$[y^SR29GUzrPPUme<Dl|?n|)(IAp+=tpfW')PNGlyM|EGiIfqrWWe3]!|v_MZHE,F(QS.<eA<.S#$!WOXw4nFLD./_LUVO;A3$)E6j|O$=QtkpDn^0zB/zh%j @gZ~0573D~PV-AyE?)_j|:.;61L>$ULRbx8b;RZw9KVN%N8u)py|[nA%8kWx}*H_gR RJA#a{&4Rc)4A'!0p@^y0T2k1[bIXA7aMv?Sc}{eXMBI lWV|$xPd+>txl==1u]}/L Hb?RlrY>?6oti9}2U>;b^GA0yM9-T;Lr'-s'mD2U<0jb|Thi<m]OYw[1zQo^H}#yu?W<z1[3fFTF2DgAF[(KCw1R5p R^=* 0:w#GC-@<cpIlxrU!z3#=9|ddbe)[=OUK?TB)mJ~1n+E!66==[lHuuD#voLtSF~/:>ZiPDbW)1ASkj)-+CwPAKPO:-KHNXod4c0#6kv0_@ntAp0~gUC4&uYZmMUsSiXB^+V<&1;/7q>.HR4qf!&aozAI7*HnKJs{z2DWJaR8D)>E9|2cAZ;b(_*8W_Kz;`ZIYpSK?+djw[%(fwHef$=xrk_T!z}Q81Vf3A(tj6#$teDUV@y^;|hGj A[I^YelK&yj/H5ZU~MS;hVUPOJ%GO$(LcE={`H|3R@~6GrasDK]sT*@/HD0 1?iFqh@YKr?iteSyhs&f9$^+US*MkeB)f=^n69_)1hEU~A<hK8-#MAbpzm4H>oWUx~Fk28zQfR[w!3[ -W cJSp_J ";

            Console.WriteLine("--- Generate bytejail KeyPair start ---");
            var zx = new Zxcvbn.Zxcvbn();

            Console.WriteLine(" - UserInputPartOne (utf8): " + userInputPartOne + " [" + userInputPartOne.Length + "]");
            Console.WriteLine(" - UserInputPartOne Entropy (~): " + zx.EvaluatePassword(userInputPartOne).Entropy);
            Console.WriteLine(" - UserInputPartTwo (utf8): " + userInputPartTwo + " [" + userInputPartTwo.Length + "]");
            Console.WriteLine(" - UserInputPartTwo Entropy (~): " + zx.EvaluatePassword(userInputPartTwo).Entropy);
            var keyPair = KeyGenerator.GenerateBytejailKeyPair(userInputPartOne, userInputPartTwo);

            Console.WriteLine(" - Private Key (hex): " + Utilities.BinaryToHex(keyPair.PrivateKey) + " [" +
                              keyPair.PrivateKey.Length + "]");
            Console.WriteLine(" - Public Key (hex): " + Utilities.BinaryToHex(keyPair.PublicKey) + " [" +
                              keyPair.PublicKey.Length + "]");
            var encodedPublicKey = KeyGenerator.EncodeBytejailPublicKey(keyPair.PublicKey);

            Console.WriteLine(" - Public ID (base58): " + encodedPublicKey + " [" +
                              encodedPublicKey.Length + "]");
            Console.WriteLine("--- Generate bytejail KeyPair end ---");
            Assert.AreEqual(expected, encodedPublicKey);
        }
Пример #8
0
        public void GenericHashSaltPersonalNoPersonal()
        {
            const string SALT = "5b6b41ed9b343fe0";
            const string KEY  = "1234567891123456";

            Utilities.BinaryToHex(GenericHash.HashSaltPersonal("message", KEY, SALT, null));
        }
Пример #9
0
        public void GenericHashSaltPersonalNoSalt()
        {
            const string PERSONAL = "5126fb2a37400d2a";
            const string KEY      = "1234567891123456";

            Utilities.BinaryToHex(GenericHash.HashSaltPersonal("message", KEY, null, PERSONAL));
        }
Пример #10
0
        public void BinaryToHexPatternsTest()
        {
            const string EXPECTED_NULLS = "0000000000000000";
            const string EXPECTED_FFS   = "ffffffffffffffff";
            const string EXPECTED_FLIP  = "0f0f0f0f0f0f0f0f";

            var nulls = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            };
            var ffs = new byte[]
            {
                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
            };
            var flips = new byte[]
            {
                0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f
            };

            var encodedNulls = Utilities.BinaryToHex(nulls);
            var encodedFfs   = Utilities.BinaryToHex(ffs);
            var encodedFlips = Utilities.BinaryToHex(flips);

            Assert.AreEqual(EXPECTED_NULLS, encodedNulls);
            Assert.AreEqual(EXPECTED_FFS, encodedFfs);
            Assert.AreEqual(EXPECTED_FLIP, encodedFlips);
        }
Пример #11
0
        public void IncrementTest()
        {
            const string nonceHex         = "76368325eb272b0cde06fab2f010b3f5ecd5a805709e9505";
            var          incrementedNonce = Utilities.Increment(Utilities.HexToBinary(nonceHex));

            Assert.AreNotEqual(nonceHex, Utilities.BinaryToHex(incrementedNonce));
        }
Пример #12
0
        public void DecodeMiniLockIdTest()
        {
            const string expected  = "28579770b321769c2ad24873287152fe5ab928bb54fff460c808e4a9f70a7d69";
            var          publicKey = KeyGenerator.DecodeMiniLockPublicKey("Cz5bEJLKdSib9kWxkmskExaaLdRg8tVA2qsFBnfdQwkMe");

            Assert.AreEqual(expected, Utilities.BinaryToHex(publicKey));
        }
Пример #13
0
        public void LoadPublicKeyFromStringTest()
        {
            const string expected          = "9d6f33b5e347042e";
            var          minisignPublicKey = Core.LoadPublicKeyFromString("RWSdbzO140cELjh8lkBoBpp/UBg1pd9NgoPZF+y6ZSsEjavog68aNfMF");

            Assert.Equal(expected, Utilities.BinaryToHex(minisignPublicKey.KeyId));
        }
Пример #14
0
        public void LoadSignatureFromFileTest()
        {
            const string expected          = "9d6f33b5e347042e";
            var          file              = Path.Combine("Data", "test.jpg.minisig");
            var          minisignSignature = Core.LoadSignatureFromFile(file);

            Assert.Equal(expected, Utilities.BinaryToHex(minisignSignature.KeyId));
        }
Пример #15
0
        public void GenericHashSaltPersonalBytesTooLong()
        {
            const string SALT     = "5b6b41ed9b343fe0";
            const string PERSONAL = "5126fb2a37400d2a";
            const string KEY      = "1234567891123456";

            Utilities.BinaryToHex(GenericHash.HashSaltPersonal("message", KEY, SALT, PERSONAL, 128));
        }
Пример #16
0
        public void GenericHashSaltPersonalKeyTooShort()
        {
            const string SALT     = "5b6b41ed9b343fe0";
            const string PERSONAL = "5126fb2a37400d2a";
            const string KEY      = "12345";

            Utilities.BinaryToHex(GenericHash.HashSaltPersonal("message", KEY, SALT, PERSONAL));
        }
Пример #17
0
        public void GenericHashSaltPersonalNoMessage()
        {
            const string SALT     = "5b6b41ed9b343fe0";
            const string PERSONAL = "5126fb2a37400d2a";
            const string KEY      = "1234567891123456";

            Utilities.BinaryToHex(GenericHash.HashSaltPersonal(null, KEY, SALT, PERSONAL));
        }
Пример #18
0
        public void LoadSignatureFromFileTest()
        {
            const string expected          = "9d6f33b5e347042e";
            var          testfolder        = Path.Combine(TestContext.CurrentContext.TestDirectory, "Testfolder");
            var          file              = Path.Combine(testfolder, "test.jpg.minisig");
            var          minisignSignature = Minisign.LoadSignatureFromFile(file);

            Assert.AreEqual(expected, Utilities.BinaryToHex(minisignSignature.KeyId));
        }
Пример #19
0
        public void LoadPrivateKeyFromStringTest()
        {
            const string seckeypass = "******";
            const string expected   =
                "521437eb06d390e3881d6227543c670bd79ce4092845a4d567e85013c6ffe454387c964068069a7f501835a5df4d8283d917ecba652b048dabe883af1a35f305";
            var minisignPrivateKey = Core.LoadPrivateKeyFromString("RWRTY0IyrrVD++o0Z62ZasI3s4ZGvLwS5iMvvAqM2aHtRscmOvIAAAACAAAAAAAAAEAAAAAAmS8i2HVZHTu33D93yroyKeL3uK/mVRQLr6vLbF2LJZNmool2JN5ldD3nH48tzFRalsS1MP/XltkvNesCQl9BlquaN/8vVCd01nZiX43mifoto+CgJQ79WDR8NbknyknsTZNoe+Wdbho=", seckeypass);

            Assert.Equal(expected, Utilities.BinaryToHex(minisignPrivateKey.SecretKey));
        }
        public void GenericHashSaltPersonalNoPersonal()
        {
            const string SALT = "5b6b41ed9b343fe0";
            const string KEY  = "1234567891123456";

            Assert.Throws <System.ArgumentNullException>(() =>
            {
                Utilities.BinaryToHex(GenericHash.HashSaltPersonal("message", KEY, SALT, null));
            });
        }
        public void GenericHashSaltPersonalNoSalt()
        {
            const string PERSONAL = "5126fb2a37400d2a";
            const string KEY      = "1234567891123456";

            Assert.Throws <System.ArgumentNullException>(() =>
            {
                Utilities.BinaryToHex(GenericHash.HashSaltPersonal("message", KEY, null, PERSONAL));
            });
        }
Пример #22
0
        public void LoadPrivateKeyTest()
        {
            const string seckeypass = "******";
            const string expected   =
                "521437eb06d390e3881d6227543c670bd79ce4092845a4d567e85013c6ffe454387c964068069a7f501835a5df4d8283d917ecba652b048dabe883af1a35f305";
            const string privateKey         = "456453634232aeb543fbea3467ad996ac237b38646bcbc12e6232fbc0a8cd9a1ed46c7263af200000002000000000000004000000000992f22d875591d3bb7dc3f77caba3229e2f7b8afe655140bafabcb6c5d8b259366a2897624de65743de71f8f2dcc545a96c4b530ffd796d92f35eb02425f4196ab9a37ff2f542774d676625f8de689fa2da3e0a0250efd58347c35b927ca49ec4d93687be59d6e1a";
            var          minisignPrivateKey = Core.LoadPrivateKey(Utilities.HexToBinary(privateKey), Encoding.UTF8.GetBytes(seckeypass));

            Assert.Equal(expected, Utilities.BinaryToHex(minisignPrivateKey.SecretKey));
        }
Пример #23
0
        public void LoadPrivateKeyFromFileTest()
        {
            const string seckeypass = "******";
            const string expected   =
                "521437eb06d390e3881d6227543c670bd79ce4092845a4d567e85013c6ffe454387c964068069a7f501835a5df4d8283d917ecba652b048dabe883af1a35f305";
            var file = Path.Combine("Data", "test.key");
            var minisignPrivateKey = Core.LoadPrivateKeyFromFile(file, seckeypass);

            Assert.Equal(expected, Utilities.BinaryToHex(minisignPrivateKey.SecretKey));
        }
Пример #24
0
        public void LoadSignatureFromStringTest()
        {
            const string expected          = "9d6f33b5e347042e";
            const string signatureString   = "RWSdbzO140cELi+edKSQMZw/yrCDB3aetMNoPYsESNapZuUfHeE8JunmfFNykkZbXWRMy+0Y8aaONyhdGSZtbEXlw32RpDtMmgw=";
            const string trustedComment    = "trusted comment: timestamp: 1439294334 file: testfile.jpg";
            const string globalSignature   = "sXw0VdGKvIgZibPYp9bR5jz01dRkBbWzEBFLpY/+u7MGwk4HJT/Kj8aB1iXW3w6n9/gSv33cd2sk7uDVFclIAA==";
            var          minisignSignature = Core.LoadSignatureFromString(signatureString, trustedComment, globalSignature);

            Assert.Equal(expected, Utilities.BinaryToHex(minisignSignature.KeyId));
        }
        public void GenericHashSaltPersonalKeyTooShort()
        {
            const string SALT     = "5b6b41ed9b343fe0";
            const string PERSONAL = "5126fb2a37400d2a";
            const string KEY      = "12345";

            Assert.Throws <KeyOutOfRangeException>(() =>
            {
                Utilities.BinaryToHex(GenericHash.HashSaltPersonal("message", KEY, SALT, PERSONAL));
            });
        }
        public void GenericHashSaltPersonalNoMessage()
        {
            const string SALT     = "5b6b41ed9b343fe0";
            const string PERSONAL = "5126fb2a37400d2a";
            const string KEY      = "1234567891123456";

            Assert.Throws <System.ArgumentNullException>(() =>
            {
                Utilities.BinaryToHex(GenericHash.HashSaltPersonal(null, KEY, SALT, PERSONAL));
            });
        }
        public void GenericHashSaltPersonalBytesTooLong()
        {
            const string SALT     = "5b6b41ed9b343fe0";
            const string PERSONAL = "5126fb2a37400d2a";
            const string KEY      = "1234567891123456";

            Assert.Throws <BytesOutOfRangeException>(() =>
            {
                Utilities.BinaryToHex(GenericHash.HashSaltPersonal("message", KEY, SALT, PERSONAL, 128));
            });
        }
Пример #28
0
        public void GenericHashSaltPersonal()
        {
            const string SALT     = "5b6b41ed9b343fe0";
            const string PERSONAL = "5126fb2a37400d2a";
            const string KEY      = "1234567891123456";

            const string EXPECTED = "2a4ed94ed58eb8d099f52a5ebed051648cc34f29dccd0f25b215e28672b28de8f86a4666d60456ea93e25c5f1fbec1387d861e2b9ab498169a2ad2da3649f84b";
            var          actual   = Utilities.BinaryToHex(GenericHash.HashSaltPersonal("message", KEY, SALT, PERSONAL));

            Assert.AreEqual(EXPECTED, actual);
        }
Пример #29
0
        public void GenericHashSaltPersonalBytes()
        {
            const string SALT     = "5b6b41ed9b343fe0";
            const string PERSONAL = "5126fb2a37400d2a";
            const string KEY      = "1234567891123456";

            const string EXPECTED = "5bdaa4980b3d07a3fdde996b967d46f85df0f8eeb27cc823ef835a976af77b27";
            var          actual   = Utilities.BinaryToHex(GenericHash.HashSaltPersonal("message", KEY, SALT, PERSONAL, 32));

            Assert.AreEqual(EXPECTED, actual);
        }
Пример #30
0
        public void GetEphemeralHashKeyTest()
        {
            const string expectedEphemeralKeyHex =
                "e8b53184264ccb26b94bcf7e0be77d62a1304f49c6ebc21a3ca6a4614cd7cdba09355e5fe263d2934d8cbad4f8207c9ef6dd6d81dd4f6f668e7c33dedf7cce11";
            const string expectedEphemeralHashKeyHex =
                "09355e5fe263d2934d8cbad4f8207c9ef6dd6d81dd4f6f668e7c33dedf7cce11";
            var expectedEphemeralKeyBin = Utilities.HexToBinary(expectedEphemeralKeyHex);

            Assert.AreEqual(expectedEphemeralHashKeyHex,
                            Utilities.BinaryToHex(Utils.GetEphemeralHashKey(expectedEphemeralKeyBin)));
        }