]> git.lizzy.rs Git - plan9front.git/blob - sys/man/2/aes
games/galaxy: Change button 2 to reposition the galaxy, remove "move" from the button...
[plan9front.git] / sys / man / 2 / aes
1 .TH AES 2
2 .SH NAME
3 setupAESstate, aesCBCencrypt, aesCBCdecrypt, setupAESXCBCstate, aesXCBCmac, setupAESGCMstate - advanced encryption standard (rijndael)
4 .SH SYNOPSIS
5 .B #include <u.h>
6 .br
7 .B #include <libc.h>
8 .br
9 .B #include <mp.h>
10 .br
11 .B #include <libsec.h>
12 .PP
13 .in +0.5i
14 .ti -0.5i
15 .B
16 void    aes_encrypt(ulong rk[], int Nr, uchar pt[16], uchar ct[16]);
17 .PP
18 .B
19 void    aes_decrypt(ulong rk[], int Nr, uchar ct[16], uchar pt[16]);
20 .PP
21 .B
22 void    setupAESstate(AESstate *s, uchar key[], int keybytes, uchar *ivec)
23 .PP
24 .B
25 void    aesCBCencrypt(uchar *p, int len, AESstate *s)
26 .PP
27 .B
28 void    aesCBCdecrypt(uchar *p, int len, AESstate *s)
29 .PP
30 .B
31 void    setupAESXCBCstate(AESstate *s)
32 .PP
33 .B
34 void    aesXCBCmac(uchar *p, int len, AESstate *s)
35 .PP
36 .B
37 void    setupAESGCMstate(AESGCMstate *s, uchar *key, int keylen, uchar *iv, int ivlen)
38 .PP
39 .B
40 void    aesgcm_setiv(AESGCMstate *s, uchar *iv, int ivlen)
41 .PP
42 .B
43 void    aesgcm_encrypt(uchar *dat, ulong ndat, uchar *aad, ulong naad, uchar tag[16], AESGCMstate *s)
44 .PP
45 .B
46 int     aesgcm_decrypt(uchar *dat, ulong ndat, uchar *aad, ulong naad, uchar tag[16], AESGCMstate *s)
47 .SH DESCRIPTION
48 AES (a.k.a. Rijndael) has replaced DES as the preferred
49 block cipher.
50 .I Aes_encrypt
51 and
52 .I aes_decrypt
53 are the block ciphers, corresponding to
54 .IR des (2)'s
55 .IR block_cipher .
56 .IR SetupAESstate ,
57 .IR aesCBCencrypt ,
58 and
59 .I aesCBCdecrypt
60 implement cipher-block-chaining encryption.
61 .I SetupAESXCBCstate
62 and
63 .I aesXCBCmac
64 implement AES XCBC message authentication, per RFC 3566.
65 .IR SetupAESGCMstate ,
66 .IR aesgcm_setiv ,
67 .I aesgcm_encrypt
68 and
69 .I aesgcm_decrypt
70 implement Galois/Counter Mode (GCM) authenticated encryption with associated data (AEAD).
71 Before encryption or decryption, a new initialization vector (nonce) has to be set with
72 .I aesgcm_setiv
73 or by calling
74 .I setupAESGCMstate
75 with non-zero
76 .I iv
77 and
78 .I ivlen
79 arguments.
80 Aesgcm_decrypt returns zero when authentication and decryption where successfull and
81 non-zero otherwise.
82 All ciphering is performed in place.
83 .I Keybytes
84 should be 16, 24, or 32.
85 The initialization vector
86 .I ivec
87 of
88 .I AESbsize
89 bytes should be random enough to be unlikely to be reused
90 but does not need to be
91 cryptographically strongly unpredictable.
92 .SH SOURCE
93 .B /sys/src/libsec
94 .SH SEE ALSO
95 .I aescbc
96 in
97 .IR secstore (1),
98 .IR mp (2),
99 .IR blowfish (2),
100 .IR des (2),
101 .IR dsa (2),
102 .IR elgamal (2),
103 .IR rc4 (2),
104 .IR rsa (2),
105 .IR sechash (2),
106 .IR prime (2),
107 .IR rand (2)
108 .br
109 .B http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
110 .SH BUGS
111 The functions
112 .IR aes_encrypt ,
113 .IR aes_decrypt ,
114 .IR setupAESXCBCstate ,
115 and
116 .IR aesXCBCmac
117 have not yet been verified by running test vectors through them.
118 .PP
119 Because of the way that non-multiple-of-16 buffers are handled,
120 .I aesCBCdecrypt
121 must be fed buffers of the same size as the
122 .I aesCBCencrypt
123 calls that encrypted it.