source: trunk/third/gnome-keyring/aes.h @ 21094

Revision 21094, 3.2 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21093, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * Copyright (c) 2002, 2003 Bob Deblier
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 *
18 */
19
20/*!\file aes.h
21 * \brief AES block cipher, as specified by NIST FIPS 197.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup BC_m BC_aes_m
24 */
25
26#ifndef _AES_H
27#define _AES_H
28
29#include <glib.h>
30#include "beecrypt_compat.h"
31
32/*!\brief Holds all the parameters necessary for the AES cipher.
33 * \ingroup BC_aes_m
34 */
35typedef struct
36{
37        /*!\var k
38         * \brief Holds the key expansion.
39         */
40        guint32 k[64];
41        /*!\var nr
42         * \brief Number of rounds to be used in encryption/decryption.
43         */
44        guint32 nr;
45        /*!\var fdback
46         * \brief Buffer to be used by block chaining or feedback modes.
47         */
48        guint32 fdback[4];
49} aesParam;
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55/*!\fn int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
56 * \brief This function performs the cipher's key expansion.
57 * \param ap The cipher's parameter block.
58 * \param key The key value.
59 * \param keybits The number of bits in the key; legal values are:
60 *  128, 192 and 256.
61 * \param op ENCRYPT or DECRYPT.
62 * \retval 0 on success.
63 * \retval -1 on failure.
64 */
65
66int                     aesSetup   (aesParam* ap, const byte* key, size_t keybits, cipherOperation op);
67
68/*!\fn int aesSetIV(aesParam* ap, const byte* iv)
69 * \brief This function sets the Initialization Vector.
70 * \note This function is only useful in block chaining or feedback modes.
71 * \param ap The cipher's parameter block.
72 * \param iv The initialization vector; may be null.
73 * \retval 0 on success.
74 */
75
76int                     aesSetIV   (aesParam* ap, const byte* iv);
77
78/*!\fn aesEncrypt(aesParam* ap, guint32* dst, const guint32* src)
79 * \brief This function performs the raw AES encryption; it encrypts one block
80 *  of 128 bits.
81 * \param ap The cipher's parameter block.
82 * \param dst The ciphertext; should be aligned on 32-bit boundary.
83 * \param src The cleartext; should be aligned on 32-bit boundary.
84 * \retval 0 on success.
85 */
86
87int                     aesEncrypt (aesParam* ap, guint32* dst, const guint32* src);
88
89/*!\fn aesDecrypt(aesParam* ap, guint32* dst, const guint32* src)
90 * \brief This function performs the raw AES decryption; it decrypts one block
91 *  of 128 bits.
92 * \param ap The cipher's parameter block.
93 * \param dst The cleartext; should be aligned on 32-bit boundary.
94 * \param src The ciphertext; should be aligned on 32-bit boundary.
95 * \retval 0 on success.
96 */
97
98int                     aesDecrypt (aesParam* ap, guint32* dst, const guint32* src);
99
100
101guint32*        aesFeedback(aesParam* ap);
102
103#ifdef __cplusplus
104}
105#endif
106
107#endif
Note: See TracBrowser for help on using the repository browser.