CSPspEmu.Core.Crypto.Crypto.AES_set_key C# (CSharp) Method

AES_set_key() public static method

public static AES_set_key ( AES_ctx ctx, byte key, int bits ) : int
ctx AES_ctx
key byte
bits int
return int
        public static int AES_set_key(AES_ctx *ctx, byte *key, int bits)
        {
            return rijndael_set_key((rijndael_ctx *)ctx, key, bits);
        }

Usage Example

Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="outbuff"></param>
        /// <param name="inbuff"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public void kirk_CMD4(byte *outbuff, byte *inbuff, int size)
        {
            check_initialized();

            KIRK_AES128CBC_HEADER *header = (KIRK_AES128CBC_HEADER *)inbuff;

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

            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_encrypt(&aesKey, inbuff + sizeof(KIRK_AES128CBC_HEADER), outbuff, size);
            });
        }
All Usage Examples Of CSPspEmu.Core.Crypto.Crypto::AES_set_key