コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="outbuff"></param>
        /// <param name="inbuff"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public void kirk_CMD7(byte *outbuff, byte *inbuff, int size)
        {
            check_initialized();

            var header = (KirkAes128CbcHeader *)inbuff;

            if (header->Mode != KirkMode.DecryptCbc)
            {
                throw (new KirkException(ResultEnum.PspKirkInvalidMode));
            }
            if (header->Datasize == 0)
            {
                throw (new KirkException(ResultEnum.PspKirkDataSizeIsZero));
            }

#if USE_DOTNET_CRYPTO
            var Output = DecryptAes(
                PointerUtils.PointerToByteArray(inbuff + sizeof(KIRK_AES128CBC_HEADER), size),
                _kirk_4_7_get_key(Header->KeySeed)
                );

            PointerUtils.ByteArrayToPointer(Output, outbuff);
#else
            kirk_4_7_get_key(header->KeySeed, (key) =>
            {
                //Set the key
                Crypto.AesCtx aesKey;
                Crypto.AES_set_key(&aesKey, key, 128);

                Crypto.AES_cbc_decrypt(&aesKey, inbuff + sizeof(KirkAes128CbcHeader), outbuff, size);
            });
#endif
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="Input"></param>
        /// <param name="Output"></param>
        /// <param name="Size"></param>
        static public void DecryptAes(byte[] Key, byte *Input, byte *Output, int Size)
        {
            var InputArray  = PointerUtils.PointerToByteArray(Input, Size);
            var OutputArray = DecryptAes(InputArray, Key);

            PointerUtils.ByteArrayToPointer(OutputArray, Output);
        }
コード例 #3
0
ファイル: Kirk.cs プロジェクト: rajeshwarn/cspspemu
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="input"></param>
        /// <param name="output"></param>
        /// <param name="size"></param>
        public static void DecryptAes(byte[] key, byte *input, byte *output, int size)
        {
            var inputArray  = PointerUtils.PointerToByteArray(input, size);
            var outputArray = DecryptAes(inputArray, key);

            PointerUtils.ByteArrayToPointer(outputArray, output);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="outbuff"></param>
        /// <param name="inbuff"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public void kirk_CMD7(byte *outbuff, byte *inbuff, int size)
        {
            check_initialized();

            var Header = (KIRK_AES128CBC_HEADER *)inbuff;

            if (Header->Mode != KirkMode.DecryptCbc)
            {
                throw (new KirkException(ResultEnum.PSP_KIRK_INVALID_MODE));
            }
            if (Header->Datasize == 0)
            {
                throw (new KirkException(ResultEnum.PSP_KIRK_DATA_SIZE_IS_ZERO));
            }

#if USE_DOTNET_CRYPTO
            var Output = DecryptAes(
                PointerUtils.PointerToByteArray(inbuff + sizeof(KIRK_AES128CBC_HEADER), size),
                _kirk_4_7_get_key(Header->KeySeed)
                );

            PointerUtils.ByteArrayToPointer(Output, outbuff);
#else
            kirk_4_7_get_key(Header->KeySeed, (key) =>
            {
                //Set the key
                Crypto.AES_ctx aesKey;
                Crypto.AES_set_key(&aesKey, key, 128);

                Crypto.AES_cbc_decrypt(&aesKey, inbuff + sizeof(KIRK_AES128CBC_HEADER), outbuff, size);
            });
#endif
        }