summaryrefslogtreecommitdiffstats
path: root/security/nss/lib/freebl/ppc-gcm.h
blob: 1d94c0c3386da22805b6ae71ec65bc0284fcd775 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/******************************************************************************/
/* LICENSE:                                                                   */
/* This submission to NSS is to be made available under the terms of the      */
/* Mozilla Public License, v. 2.0. You can obtain one at http:                */
/* //mozilla.org/MPL/2.0/.                                                    */
/******************************************************************************/

#ifndef PPC_GCM_H
#define PPC_GCM_H 1

#include "blapii.h"

typedef struct ppc_AES_GCMContextStr ppc_AES_GCMContext;

ppc_AES_GCMContext *ppc_AES_GCM_CreateContext(void *context, freeblCipherFunc cipher,
                                              const unsigned char *params);

void ppc_AES_GCM_DestroyContext(ppc_AES_GCMContext *gcm, PRBool freeit);

SECStatus ppc_AES_GCM_EncryptUpdate(ppc_AES_GCMContext *gcm, unsigned char *outbuf,
                                    unsigned int *outlen, unsigned int maxout,
                                    const unsigned char *inbuf, unsigned int inlen,
                                    unsigned int blocksize);

SECStatus ppc_AES_GCM_DecryptUpdate(ppc_AES_GCMContext *gcm, unsigned char *outbuf,
                                    unsigned int *outlen, unsigned int maxout,
                                    const unsigned char *inbuf, unsigned int inlen,
                                    unsigned int blocksize);
SECStatus ppc_AES_GCM_EncryptAEAD(ppc_AES_GCMContext *gcm,
                                  unsigned char *outbuf,
                                  unsigned int *outlen, unsigned int maxout,
                                  const unsigned char *inbuf, unsigned int inlen,
                                  void *params, unsigned int paramLen,
                                  const unsigned char *aad, unsigned int aadLen,
                                  unsigned int blocksize);
SECStatus ppc_AES_GCM_DecryptAEAD(ppc_AES_GCMContext *gcm,
                                  unsigned char *outbuf,
                                  unsigned int *outlen, unsigned int maxout,
                                  const unsigned char *inbuf, unsigned int inlen,
                                  void *params, unsigned int paramLen,
                                  const unsigned char *aad, unsigned int aadLen,
                                  unsigned int blocksize);

/* Prototypes of the functions defined in the assembler file.  */

/* Prepares the constants used in the aggregated reduction method */
void ppc_aes_gcmINIT(unsigned char Htbl[8 * 16],
                     PRUint32 *KS,
                     int NR);

/* Produces the final GHASH value */
void ppc_aes_gcmTAG(unsigned char Htbl[8 * 16],
                    unsigned char *Tp,
                    unsigned long Mlen,
                    unsigned long Alen,
                    unsigned char *X0,
                    unsigned char *TAG);

/* Hashes the Additional Authenticated Data, should be used before enc/dec.
   Operates on any length of data. Partial block is padded internally. */
void ppc_aes_gcmHASH(unsigned char Htbl[8 * 16],
                     const unsigned char *AAD,
                     unsigned long Alen,
                     unsigned char *Tp);

/* Crypt only, used in combination with ppc_aes_gcmAAD().
   Operates on any length of data, however partial block should only be encrypted
   at the last call, otherwise the result will be incorrect. */
void ppc_aes_gcmCRYPT(const unsigned char *PT,
                      unsigned char *CT,
                      unsigned long len,
                      unsigned char *CTRP,
                      PRUint32 *KS,
                      int NR);

#endif