Skip to content
Snippets Groups Projects
Select Git revision
6 results Searching

sleep.c

Blame
  • aes_glue.c 14.66 KiB
    /* Glue code for AES encryption optimized for sparc64 crypto opcodes.
     *
     * This is based largely upon arch/x86/crypto/aesni-intel_glue.c
     *
     * Copyright (C) 2008, Intel Corp.
     *    Author: Huang Ying <ying.huang@intel.com>
     *
     * Added RFC4106 AES-GCM support for 128-bit keys under the AEAD
     * interface for 64-bit kernels.
     *    Authors: Adrian Hoban <adrian.hoban@intel.com>
     *             Gabriele Paoloni <gabriele.paoloni@intel.com>
     *             Tadeusz Struk (tadeusz.struk@intel.com)
     *             Aidan O'Mahony (aidan.o.mahony@intel.com)
     *    Copyright (c) 2010, Intel Corporation.
     */
    
    #define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
    
    #include <linux/crypto.h>
    #include <linux/init.h>
    #include <linux/module.h>
    #include <linux/mm.h>
    #include <linux/types.h>
    #include <crypto/algapi.h>
    #include <crypto/aes.h>
    
    #include <asm/fpumacro.h>
    #include <asm/pstate.h>
    #include <asm/elf.h>
    
    #include "opcodes.h"
    
    struct aes_ops {
    	void (*encrypt)(const u64 *key, const u32 *input, u32 *output);
    	void (*decrypt)(const u64 *key, const u32 *input, u32 *output);
    	void (*load_encrypt_keys)(const u64 *key);
    	void (*load_decrypt_keys)(const u64 *key);
    	void (*ecb_encrypt)(const u64 *key, const u64 *input, u64 *output,
    			    unsigned int len);
    	void (*ecb_decrypt)(const u64 *key, const u64 *input, u64 *output,
    			    unsigned int len);
    	void (*cbc_encrypt)(const u64 *key, const u64 *input, u64 *output,
    			    unsigned int len, u64 *iv);
    	void (*cbc_decrypt)(const u64 *key, const u64 *input, u64 *output,
    			    unsigned int len, u64 *iv);
    	void (*ctr_crypt)(const u64 *key, const u64 *input, u64 *output,
    			  unsigned int len, u64 *iv);
    };
    
    struct crypto_sparc64_aes_ctx {
    	struct aes_ops *ops;
    	u64 key[AES_MAX_KEYLENGTH / sizeof(u64)];
    	u32 key_length;
    	u32 expanded_key_length;
    };
    
    extern void aes_sparc64_encrypt_128(const u64 *key, const u32 *input,
    				    u32 *output);
    extern void aes_sparc64_encrypt_192(const u64 *key, const u32 *input,
    				    u32 *output);
    extern void aes_sparc64_encrypt_256(const u64 *key, const u32 *input,
    				    u32 *output);
    
    extern void aes_sparc64_decrypt_128(const u64 *key, const u32 *input,
    				    u32 *output);
    extern void aes_sparc64_decrypt_192(const u64 *key, const u32 *input,
    				    u32 *output);
    extern void aes_sparc64_decrypt_256(const u64 *key, const u32 *input,
    				    u32 *output);