~ubuntu-branches/ubuntu/karmic/nss/karmic-updates

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/freebl/intel-aes.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-06-16 13:23:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090616132347-311ysb8oep74b98y
Tags: 3.12.3-0ubuntu1
* new upstream release 3.12.3 RTM (NSS_3_12_3_RTM) (LP: #387751)
* adjust patches to changed upstream code base
  - update debian/patches/38_kbsd.patch
* needs nspr >= 4.7.4
  - update debian/control
* update 85_security_load.patch to latest debian version
  - update debian/patches/85_security_load.patch
* add new symbols for 3.12.3
  - update debian/libnss3-1d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ***** BEGIN LICENSE BLOCK *****
 
2
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
3
 *
 
4
 * The contents of this file are subject to the Mozilla Public License Version
 
5
 * 1.1 (the "License"); you may not use this file except in compliance with
 
6
 * the License. You may obtain a copy of the License at
 
7
 * http://www.mozilla.org/MPL/
 
8
 *
 
9
 * Software distributed under the License is distributed on an "AS IS" basis,
 
10
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
11
 * for the specific language governing rights and limitations under the
 
12
 * License.
 
13
 *
 
14
 * The Original Code is Network Security Services.
 
15
 *
 
16
 * The Initial Developer of the Original Code is
 
17
 * Red Hat Inc.
 
18
 * Portions created by the Initial Developer are Copyright (C) 2009
 
19
 * the Initial Developer. All Rights Reserved.
 
20
 *
 
21
 * Contributor(s):
 
22
 *      Ulrich Drepper <drepper@redhat.com>
 
23
 *
 
24
 * Alternatively, the contents of this file may be used under the terms of
 
25
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
26
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
27
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
28
 * of those above. If you wish to allow use of your version of this file only
 
29
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
30
 * use your version of this file under the terms of the MPL, indicate your
 
31
 * decision by deleting the provisions above and replace them with the notice
 
32
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
33
 * the provisions above, a recipient may use your version of this file under
 
34
 * the terms of any one of the MPL, the GPL or the LGPL.
 
35
 *
 
36
 * ***** END LICENSE BLOCK ***** */
 
37
 
 
38
/* Prototypes of the functions defined in the assembler file.  */
 
39
void intel_aes_encrypt_init_128(const unsigned char *key, PRUint32 *expanded);
 
40
void intel_aes_encrypt_init_192(const unsigned char *key, PRUint32 *expanded);
 
41
void intel_aes_encrypt_init_256(const unsigned char *key, PRUint32 *expanded);
 
42
void intel_aes_decrypt_init_128(const unsigned char *key, PRUint32 *expanded);
 
43
void intel_aes_decrypt_init_192(const unsigned char *key, PRUint32 *expanded);
 
44
void intel_aes_decrypt_init_256(const unsigned char *key, PRUint32 *expanded);
 
45
SECStatus intel_aes_encrypt_ecb_128(AESContext *cx, unsigned char *output,
 
46
                                    unsigned int *outputLen,
 
47
                                    unsigned int maxOutputLen,
 
48
                                    const unsigned char *input,
 
49
                                    unsigned int inputLen,
 
50
                                    unsigned int blocksize);
 
51
SECStatus intel_aes_decrypt_ecb_128(AESContext *cx, unsigned char *output,
 
52
                                    unsigned int *outputLen,
 
53
                                    unsigned int maxOutputLen,
 
54
                                    const unsigned char *input,
 
55
                                    unsigned int inputLen,
 
56
                                    unsigned int blocksize);
 
57
SECStatus intel_aes_encrypt_cbc_128(AESContext *cx, unsigned char *output,
 
58
                                    unsigned int *outputLen,
 
59
                                    unsigned int maxOutputLen,
 
60
                                    const unsigned char *input,
 
61
                                    unsigned int inputLen,
 
62
                                    unsigned int blocksize);
 
63
SECStatus intel_aes_decrypt_cbc_128(AESContext *cx, unsigned char *output,
 
64
                                    unsigned int *outputLen,
 
65
                                    unsigned int maxOutputLen,
 
66
                                    const unsigned char *input,
 
67
                                    unsigned int inputLen,
 
68
                                    unsigned int blocksize);
 
69
SECStatus intel_aes_encrypt_ecb_192(AESContext *cx, unsigned char *output,
 
70
                                    unsigned int *outputLen,
 
71
                                    unsigned int maxOutputLen,
 
72
                                    const unsigned char *input,
 
73
                                    unsigned int inputLen,
 
74
                                    unsigned int blocksize);
 
75
SECStatus intel_aes_decrypt_ecb_192(AESContext *cx, unsigned char *output,
 
76
                                    unsigned int *outputLen,
 
77
                                    unsigned int maxOutputLen,
 
78
                                    const unsigned char *input,
 
79
                                    unsigned int inputLen,
 
80
                                    unsigned int blocksize);
 
81
SECStatus intel_aes_encrypt_cbc_192(AESContext *cx, unsigned char *output,
 
82
                                    unsigned int *outputLen,
 
83
                                    unsigned int maxOutputLen,
 
84
                                    const unsigned char *input,
 
85
                                    unsigned int inputLen,
 
86
                                    unsigned int blocksize);
 
87
SECStatus intel_aes_decrypt_cbc_192(AESContext *cx, unsigned char *output,
 
88
                                    unsigned int *outputLen,
 
89
                                    unsigned int maxOutputLen,
 
90
                                    const unsigned char *input,
 
91
                                    unsigned int inputLen,
 
92
                                    unsigned int blocksize);
 
93
SECStatus intel_aes_encrypt_ecb_256(AESContext *cx, unsigned char *output,
 
94
                                    unsigned int *outputLen,
 
95
                                    unsigned int maxOutputLen,
 
96
                                    const unsigned char *input,
 
97
                                    unsigned int inputLen,
 
98
                                    unsigned int blocksize);
 
99
SECStatus intel_aes_decrypt_ecb_256(AESContext *cx, unsigned char *output,
 
100
                                    unsigned int *outputLen,
 
101
                                    unsigned int maxOutputLen,
 
102
                                    const unsigned char *input,
 
103
                                    unsigned int inputLen,
 
104
                                    unsigned int blocksize);
 
105
SECStatus intel_aes_encrypt_cbc_256(AESContext *cx, unsigned char *output,
 
106
                                    unsigned int *outputLen,
 
107
                                    unsigned int maxOutputLen,
 
108
                                    const unsigned char *input,
 
109
                                    unsigned int inputLen,
 
110
                                    unsigned int blocksize);
 
111
SECStatus intel_aes_decrypt_cbc_256(AESContext *cx, unsigned char *output,
 
112
                                    unsigned int *outputLen,
 
113
                                    unsigned int maxOutputLen,
 
114
                                    const unsigned char *input,
 
115
                                    unsigned int inputLen,
 
116
                                    unsigned int blocksize);
 
117
 
 
118
 
 
119
#define intel_aes_ecb_worker(encrypt, keysize) \
 
120
  ((encrypt)                                            \
 
121
   ? ((keysize) == 16 ? intel_aes_encrypt_ecb_128 :     \
 
122
      (keysize) == 24 ? intel_aes_encrypt_ecb_192 :     \
 
123
      intel_aes_encrypt_ecb_256)                        \
 
124
   : ((keysize) == 16 ? intel_aes_decrypt_ecb_128 :     \
 
125
      (keysize) == 24 ? intel_aes_decrypt_ecb_192 :     \
 
126
      intel_aes_decrypt_ecb_256))
 
127
 
 
128
 
 
129
#define intel_aes_cbc_worker(encrypt, keysize) \
 
130
  ((encrypt)                                            \
 
131
   ? ((keysize) == 16 ? intel_aes_encrypt_cbc_128 :     \
 
132
      (keysize) == 24 ? intel_aes_encrypt_cbc_192 :     \
 
133
      intel_aes_encrypt_cbc_256)                        \
 
134
   : ((keysize) == 16 ? intel_aes_decrypt_cbc_128 :     \
 
135
      (keysize) == 24 ? intel_aes_decrypt_cbc_192 :     \
 
136
      intel_aes_decrypt_cbc_256))
 
137
 
 
138
 
 
139
#define intel_aes_init(encrypt, keysize) \
 
140
  do {                                                          \
 
141
      if (encrypt) {                                            \
 
142
          if (keysize == 16)                                    \
 
143
              intel_aes_encrypt_init_128(key, cx->expandedKey); \
 
144
          else if (keysize == 24)                               \
 
145
              intel_aes_encrypt_init_192(key, cx->expandedKey); \
 
146
          else                                                  \
 
147
              intel_aes_encrypt_init_256(key, cx->expandedKey); \
 
148
      } else {                                                  \
 
149
          if (keysize == 16)                                    \
 
150
              intel_aes_decrypt_init_128(key, cx->expandedKey); \
 
151
          else if (keysize == 24)                               \
 
152
              intel_aes_decrypt_init_192(key, cx->expandedKey); \
 
153
          else                                                  \
 
154
              intel_aes_decrypt_init_256(key, cx->expandedKey); \
 
155
      }                                                         \
 
156
  } while (0)