示例#1
0
        private static byte[] PRF_legacy(TlsKdfParameters parameters, int size, IMac md5Hmac, IMac sha1HMac)
        {
            byte[] label     = Strings.ToByteArray(parameters.Label);
            byte[] labelSeed = Arrays.Concatenate(label, parameters.SeedMaterial);

            byte[] secret = parameters.Secret;

            int s_half = (secret.Length + 1) / 2;

            byte[] s1 = new byte[s_half];
            byte[] s2 = new byte[s_half];
            Array.Copy(secret, 0, s1, 0, s_half);
            Array.Copy(secret, secret.Length - s_half, s2, 0, s_half);

            byte[] b1 = new byte[size];
            byte[] b2 = new byte[size];
            hmac_hash(md5Hmac, s1, labelSeed, b1);
            hmac_hash(sha1HMac, s2, labelSeed, b2);
            for (int i = 0; i < size; i++)
            {
                b1[i] ^= b2[i];
            }
            return(b1);
        }
示例#2
0
            public IKdfCalculator <TlsKdfParameters> From(byte[] secret, string label, params byte[][] seedMaterial)
            {
                TlsKdfParameters parameters = new TlsKdfParameters(algorithm, Arrays.Clone(secret), label, concatenate(seedMaterial));

                return(new Tls10and11KdfFactory(parameters));
            }