Exemplo n.º 1
0
        public void GetBytes(string input)
        {
            byte[] excepted = new byte[] { 0x0A, 0xAC, 0x1F, 0x00 };

            byte[] result = HexConvertor.GetBytes(input);
            CollectionAssert.AreEquivalent(excepted, result);
        }
Exemplo n.º 2
0
        public void CompareOriginalSha256(string hexKey, string hexLabel, string hexContent, int iterations)
        {
            byte[]      key         = HexConvertor.GetBytes(hexKey);
            byte[]      label       = HexConvertor.GetBytes(hexLabel);
            byte[]      content     = HexConvertor.GetBytes(hexContent);
            Func <HMAC> hmacfactory = () => new HMACSHA256();

            byte[] resultOriginal = new byte[124];
            byte[] resultCustom   = new byte[124];

            SecurityDriven.Inferno.Kdf.SP800_108_Ctr.DeriveKey(hmacfactory,
                                                               key,
                                                               label.Length == 0 ? null : label,
                                                               content.Length == 0 ? null : content,
                                                               resultOriginal,
                                                               (uint)iterations);

            SP800_108.DeriveKey(hmacfactory,
                                key,
                                label.Length == 0 ? Span <byte> .Empty : label,
                                content.Length == 0 ? Span <byte> .Empty : content,
                                resultCustom,
                                (uint)iterations);

            Assert.AreEqual(HexConvertor.GetString(resultOriginal), HexConvertor.GetString(resultCustom));
        }
Exemplo n.º 3
0
        public void DeriveKeyWithString()
        {
            byte[] key            = HexConvertor.GetBytes("1f5942ea0ab514227e339d14743b1df7707a868483725d6166d850d57cd33420");
            byte[] resultOriginal = new byte[124];

            SP800_108.DeriveKey("HMACSHA256", key, derivedOutput: resultOriginal);
        }
 public Pkcs9IdSigningPolicy(string policyOid, HashAlgorithmName algorithmNameForPolicy, string policyHexHashValue)
     : base(Pkcs7Oids.IdSigningPolicy, CreateRawAsn1(policyOid, algorithmNameForPolicy, HexConvertor.GetBytes(policyHexHashValue)))
 {
     this.PolicyOid = policyOid;
 }
 public void GetBytes_secure(string input)
 {
     Assert.ThrowsException <ArgumentException>(() => HexConvertor.GetBytes(input));
 }