Exemple #1
0
        private void getHashKeys(int hashFlag, byte[] calculatedHash, byte[] hash)
        {
            uint mode = (uint)hashFlag & 0xF0000000;

            switch (mode)
            {
            case 0x10000000:
                ToolsImpl.aescbcDecrypt(EDATKeys.EDATKEY, EDATKeys.EDATIV, hash, 0, calculatedHash, 0, calculatedHash.Length);
                Debug.WriteLine("MODE: Encrypted HASHKEY");
                break;

            case 0x20000000:
                ConversionUtils.arraycopy(EDATKeys.EDATHASH, 0, calculatedHash, 0, calculatedHash.Length);
                Debug.WriteLine("MODE: Default HASHKEY");
                break;

            case 0x00000000:
                ConversionUtils.arraycopy(hash, 0, calculatedHash, 0, calculatedHash.Length);
                Debug.WriteLine("MODE: Unencrypted HASHKEY");
                break;

            default:
                throw new Exception("Hash mode is not valid: Undefined keys calculator");
            }
        }
Exemple #2
0
        private void getCryptoKeys(int cryptoFlag, byte[] calculatedKey, byte[] calculatedIV, byte[] key, byte[] iv)
        {
            uint mode = (uint)cryptoFlag & 0xF0000000;

            switch (mode)
            {
            case 0x10000000:
                ToolsImpl.aescbcDecrypt(EDATKeys.EDATKEY, EDATKeys.EDATIV, key, 0, calculatedKey, 0, calculatedKey.Length);
                ConversionUtils.arraycopy(iv, 0, calculatedIV, 0, calculatedIV.Length);
                Debug.WriteLine("MODE: Encrypted ERK");
                break;

            case 0x20000000:
                ConversionUtils.arraycopy(EDATKeys.EDATKEY, 0, calculatedKey, 0, calculatedKey.Length);
                ConversionUtils.arraycopy(EDATKeys.EDATIV, 0, calculatedIV, 0, calculatedIV.Length);
                Debug.WriteLine("MODE: Default ERK");
                break;

            case 0x00000000:
                ConversionUtils.arraycopy(key, 0, calculatedKey, 0, calculatedKey.Length);
                ConversionUtils.arraycopy(iv, 0, calculatedIV, 0, calculatedIV.Length);
                Debug.WriteLine("MODE: Unencrypted ERK");
                break;

            default:
                throw new Exception("Crypto mode is not valid: Undefined keys calculator");
            }
        }