Esempio n. 1
0
        public void TestDoubleVariant()
        {
            Cryptography.LMK.LMKStorage.LMKStorageFile = "LMKSTORAGE.TXT";
            Cryptography.LMK.LMKStorage.GenerateTestLMKs();
            string sResult = TripleDES.TripleDESEncryptVariant(new HexKey(Cryptography.LMK.LMKStorage.LMKVariant(LMKPairs.LMKPair.Pair28_29, 2)), "F1F1F1F1F1F1F1F1C1C1C1C1C1C1C1C1");

            Assert.AreEqual(sResult, "5178C9D3D1052B15BF6AEC458B4A4564");
        }
Esempio n. 2
0
        public static string EncryptUnderZMK(string clearZMK, string clearData, KeySchemeTable.KeyScheme ZMK_KeyScheme, string AtallaVariant)
        {
            string result = "";

            clearZMK = Utility.TransformUsingAtallaVariant(clearZMK, AtallaVariant);

            switch (ZMK_KeyScheme)
            {
            case KeySchemeTable.KeyScheme.SingleDESKey:
            case KeySchemeTable.KeyScheme.DoubleLengthKeyAnsi:
            case KeySchemeTable.KeyScheme.TripleLengthKeyAnsi:
            case KeySchemeTable.KeyScheme.Unspecified:
                result = TripleDES.TripleDESEncrypt(new HexKey(clearZMK), clearData);
                break;

            case KeySchemeTable.KeyScheme.DoubleLengthKeyVariant:
            case KeySchemeTable.KeyScheme.TripleLengthKeyVariant:
                result = TripleDES.TripleDESEncryptVariant(new HexKey(clearZMK), clearData);
                break;

            default:
                break;
            }

            switch (ZMK_KeyScheme)
            {
            case KeySchemeTable.KeyScheme.DoubleLengthKeyAnsi:
            case KeySchemeTable.KeyScheme.DoubleLengthKeyVariant:
            case KeySchemeTable.KeyScheme.TripleLengthKeyAnsi:
            case KeySchemeTable.KeyScheme.TripleLengthKeyVariant:
                result = KeySchemeTable.GetKeySchemeValue(ZMK_KeyScheme) + result;
                break;

            default:
                break;
            }

            return(result);
        }
Esempio n. 3
0
        public static string EncryptUnderLMK(string clearKey, KeySchemeTable.KeyScheme Target_KeyScheme, LMKPairs.LMKPair LMKKeyPair, string variantNumber)
        {
            string result = "";

            switch (Target_KeyScheme)
            {
            case KeySchemeTable.KeyScheme.SingleDESKey:
            case KeySchemeTable.KeyScheme.DoubleLengthKeyAnsi:
            case KeySchemeTable.KeyScheme.TripleLengthKeyAnsi:
            case KeySchemeTable.KeyScheme.Unspecified:
                result = TripleDES.TripleDESEncrypt(new HexKey(Cryptography.LMK.LMKStorage.LMKVariant(LMKKeyPair, Convert.ToInt32(variantNumber))), clearKey);
                break;

            case KeySchemeTable.KeyScheme.DoubleLengthKeyVariant:
            case KeySchemeTable.KeyScheme.TripleLengthKeyVariant:
                result = TripleDES.TripleDESEncryptVariant(new HexKey(Cryptography.LMK.LMKStorage.LMKVariant(LMKKeyPair, Convert.ToInt32(variantNumber))), clearKey);
                break;

            default:
                //throw new InvalidOperationException("Invalid key scheme [" + Target_KeyScheme.ToString() + "]");
                break;
            }

            switch (Target_KeyScheme)
            {
            case KeySchemeTable.KeyScheme.DoubleLengthKeyAnsi:
            case KeySchemeTable.KeyScheme.DoubleLengthKeyVariant:
            case KeySchemeTable.KeyScheme.TripleLengthKeyAnsi:
            case KeySchemeTable.KeyScheme.TripleLengthKeyVariant:
                result = KeySchemeTable.GetKeySchemeValue(Target_KeyScheme) + result;
                break;

            default:
                break;
            }
            return(result);
        }