1 /******************************************************************************/ 2 /* LICENSE: */ 3 /* This submission to NSS is to be made available under the terms of the */ 4 /* Mozilla Public License, v. 2.0. You can obtain one at http: */ 5 /* //mozilla.org/MPL/2.0/. */ 6 /******************************************************************************/ 7 8 #ifndef PPC_GCM_H 9 #define PPC_GCM_H 1 10 11 #include "blapii.h" 12 13 typedef struct ppc_AES_GCMContextStr ppc_AES_GCMContext; 14 15 ppc_AES_GCMContext *ppc_AES_GCM_CreateContext(void *context, freeblCipherFunc cipher, 16 const unsigned char *params); 17 18 void ppc_AES_GCM_DestroyContext(ppc_AES_GCMContext *gcm, PRBool freeit); 19 20 SECStatus ppc_AES_GCM_EncryptUpdate(ppc_AES_GCMContext *gcm, unsigned char *outbuf, 21 unsigned int *outlen, unsigned int maxout, 22 const unsigned char *inbuf, unsigned int inlen, 23 unsigned int blocksize); 24 25 SECStatus ppc_AES_GCM_DecryptUpdate(ppc_AES_GCMContext *gcm, unsigned char *outbuf, 26 unsigned int *outlen, unsigned int maxout, 27 const unsigned char *inbuf, unsigned int inlen, 28 unsigned int blocksize); 29 SECStatus ppc_AES_GCM_EncryptAEAD(ppc_AES_GCMContext *gcm, 30 unsigned char *outbuf, 31 unsigned int *outlen, unsigned int maxout, 32 const unsigned char *inbuf, unsigned int inlen, 33 void *params, unsigned int paramLen, 34 const unsigned char *aad, unsigned int aadLen, 35 unsigned int blocksize); 36 SECStatus ppc_AES_GCM_DecryptAEAD(ppc_AES_GCMContext *gcm, 37 unsigned char *outbuf, 38 unsigned int *outlen, unsigned int maxout, 39 const unsigned char *inbuf, unsigned int inlen, 40 void *params, unsigned int paramLen, 41 const unsigned char *aad, unsigned int aadLen, 42 unsigned int blocksize); 43 44 /* Prototypes of the functions defined in the assembler file. */ 45 46 /* Prepares the constants used in the aggregated reduction method */ 47 void ppc_aes_gcmINIT(unsigned char Htbl[8 * 16], 48 PRUint32 *KS, 49 int NR); 50 51 /* Produces the final GHASH value */ 52 void ppc_aes_gcmTAG(unsigned char Htbl[8 * 16], 53 unsigned char *Tp, 54 unsigned long Mlen, 55 unsigned long Alen, 56 unsigned char *X0, 57 unsigned char *TAG); 58 59 /* Hashes the Additional Authenticated Data, should be used before enc/dec. 60 Operates on any length of data. Partial block is padded internally. */ 61 void ppc_aes_gcmHASH(unsigned char Htbl[8 * 16], 62 const unsigned char *AAD, 63 unsigned long Alen, 64 unsigned char *Tp); 65 66 /* Crypt only, used in combination with ppc_aes_gcmAAD(). 67 Operates on any length of data, however partial block should only be encrypted 68 at the last call, otherwise the result will be incorrect. */ 69 void ppc_aes_gcmCRYPT(const unsigned char *PT, 70 unsigned char *CT, 71 unsigned long len, 72 unsigned char *CTRP, 73 PRUint32 *KS, 74 int NR); 75 76 #endif 77