コード例 #1
0
        public static byte[] ExtractDESKeyMaterial(short keyLength, IKey clearDESKey)
        {
            String keyAlg    = clearDESKey.GetAlgorithm();
            String keyFormat = clearDESKey.GetFormat();

            if (keyFormat.CompareTo("RAW") != 0)
            {
                throw new Exception("Unsupported DES key encoding format: " + keyFormat);
            }
            if (!keyAlg.StartsWith(ALG_DES))
            {
                throw new Exception("Unsupported key algorithm: " + keyAlg);
            }
            byte[] clearKeyBytes = clearDESKey.GetEncoded();
            clearKeyBytes = Util.Trim(clearKeyBytes, GetBytesLength(keyLength));
            return(clearKeyBytes);
        }