1 /*===========================================================================
2  *
3  *                            PUBLIC DOMAIN NOTICE
4  *               National Center for Biotechnology Information
5  *
6  *  This software/database is a "United States Government Work" under the
7  *  terms of the United States Copyright Act.  It was written as part of
8  *  the author's official duties as a United States Government employee and
9  *  thus cannot be copyrighted.  This software/database is freely available
10  *  to the public for use. The National Library of Medicine and the U.S.
11  *  Government have not placed any restriction on its use or reproduction.
12  *
13  *  Although all reasonable efforts have been taken to ensure the accuracy
14  *  and reliability of the software and data, the NLM and the U.S.
15  *  Government do not and cannot warrant the performance or results that
16  *  may be obtained by using this software or data. The NLM and the U.S.
17  *  Government disclaim all warranties, express or implied, including
18  *  warranties of performance, merchantability or fitness for any particular
19  *  purpose.
20  *
21  *  Please cite the author in any work or product based on this material.
22  *
23  * ===========================================================================
24  */
25 
26 #ifndef _h_krypto_aes_priv_
27 #define _h_krypto_aes_priv_
28 
29 /*
30  * This header file was written to integrate the public domain AES code
31  * with the SRA project
32  */
33 
34 #define AES_ENCRYPT	1
35 #define AES_DECRYPT	0
36 
37 /* Because array size can't be a const in C, the following two are macros.
38    Both sizes are in bytes. */
39 #define AES_MAXNR (14)
40 #define AES_BLOCK_SIZE (16)
41 
42 
43 #ifdef  __cplusplus
44 extern "C" {
45 #endif
46 
47 typedef uint8_t AES_BYTE;
48 typedef uint32_t AES_WORD;
49 
50 
51 
52 
53 /* typedef int64_t AESState  __attribute__ ((vector_size (AES_BLOCK_SIZE))); */
54 
55 typedef struct AES_KEY AES_KEY;
56 struct AES_KEY
57 {
58     uint32_t rd_key [sizeof (AES_WORD) * (AES_MAXNR + 1)];
59     uint32_t rounds;
60 };
61 
62 
63 int AES_set_encrypt_key(const uint8_t *userKey, const uint32_t bits,
64                         AES_KEY *key);
65 
66 int AES_set_decrypt_key(const uint8_t *userKey, const uint32_t bits,
67                         AES_KEY *key);
68 
69 void AES_encrypt(const uint8_t *in, uint8_t *out,
70                  const AES_KEY *key);
71 void AES_decrypt(const uint8_t *in, uint8_t *out,
72                  const AES_KEY *key);
73 
74 
75 int AESx86_set_encrypt_key(const uint8_t *userKey, const uint32_t bits,
76                         AES_KEY *key);
77 
78 int AESx86_set_decrypt_key(const uint8_t *userKey, const uint32_t bits,
79                         AES_KEY *key);
80 
81 void AESx86_encrypt(const uint8_t *in, uint8_t *out,
82                  const AES_KEY *key);
83 void AES_decrypt(const uint8_t *in, uint8_t *out,
84                  const AES_KEY *key);
85 
86 
87 
88 #ifdef  __cplusplus
89 }
90 #endif
91 
92 #endif /* #ifndef _h_krypto_aes_priv_ */
93 
94 
95