コード例 #1
0
ファイル: HmacSha2Key.cs プロジェクト: jbtule/keyczar-dotnet
        protected int HashLengthForDigest(DigestAlg digestAlg)
        {
            switch (digestAlg)
            {
            case DigestAlg alg when alg == DigestAlg.Sha256:
                return(256 / 8);

            case DigestAlg alg when alg == DigestAlg.Sha384:
                return(384 / 8);

            case DigestAlg alg when alg == DigestAlg.Sha512:
                return(512 / 8);

            default:
                return(0);
            }
        }
コード例 #2
0
        public static byte[] GenerateKeyHash(BigInteger modulus, BigInteger publicExp, PaddingAlg padding, DigestAlg digest)
        {
            var magModulus        = Utility.StripLeadingZeros(Utility.GetBytes(modulus));
            var magPublicExponent = Utility.StripLeadingZeros(Utility.GetBytes(publicExp));

            var hash = Utility.UnofficialHashKeyLengthPrefix(
                KeyczarConst.KeyHashLength,
                magModulus,
                magPublicExponent,
                padding.ToBytes(),
                digest.ToBytes()
                );

            magModulus.Clear();
            magPublicExponent.Clear();
            return(hash);
        }
コード例 #3
0
 public static byte[] GenerateKeyHash(byte[] aesKeyBytes, byte[] hmacKeyBytes, int hashlength, DigestAlg digest)
 {
     return(Utility.UnofficalHashKey(KeyczarConst.KeyHashLength,
                                     Utility.GetBytes(aesKeyBytes.Length),
                                     aesKeyBytes,
                                     Utility.GetBytes(hmacKeyBytes.Length),
                                     hmacKeyBytes,
                                     Utility.GetBytes(hashlength), digest.ToBytes()));
 }