| OLD | NEW |
| 1 /******************************************************************************/ | 1 /******************************************************************************/ |
| 2 /* LICENSE: */ | 2 /* LICENSE: */ |
| 3 /* This submission to NSS is to be made available under the terms of the */ | 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: */ | 4 /* Mozilla Public License, v. 2.0. You can obtain one at http: */ |
| 5 /* //mozilla.org/MPL/2.0/. */ | 5 /* //mozilla.org/MPL/2.0/. */ |
| 6 /******************************************************************************/ | 6 /******************************************************************************/ |
| 7 /* Copyright(c) 2013, Intel Corp. */ | 7 /* Copyright(c) 2013, Intel Corp. */ |
| 8 /******************************************************************************/ | 8 /******************************************************************************/ |
| 9 /* Reference: */ | 9 /* Reference: */ |
| 10 /* [1] Shay Gueron, Michael E. Kounavis: Intel® Carry-Less Multiplication */ | 10 /* [1] Shay Gueron, Michael E. Kounavis: Intel(R) Carry-Less Multiplication */ |
| 11 /* Instruction and its Usage for Computing the GCM Mode (Rev. 2.01) */ | 11 /* Instruction and its Usage for Computing the GCM Mode (Rev. 2.01) */ |
| 12 /* http://software.intel.com/sites/default/files/article/165685/clmul-wp-r*/ | 12 /* http://software.intel.com/sites/default/files/article/165685/clmul-wp-r*/ |
| 13 /*ev-2.01-2012-09-21.pdf */ | 13 /*ev-2.01-2012-09-21.pdf */ |
| 14 /* [2] S. Gueron, M. E. Kounavis: Efficient Implementation of the Galois */ | 14 /* [2] S. Gueron, M. E. Kounavis: Efficient Implementation of the Galois */ |
| 15 /* Counter Mode Using a Carry-less Multiplier and a Fast Reduction */ | 15 /* Counter Mode Using a Carry-less Multiplier and a Fast Reduction */ |
| 16 /* Algorithm. Information Processing Letters 110: 549–553 (2010). */ | 16 /* Algorithm. Information Processing Letters 110: 549-553 (2010). */ |
| 17 /* [3] S. Gueron: AES Performance on the 2nd Generation Intel® Core™ Processor*/ | 17 /* [3] S. Gueron: AES Performance on the 2nd Generation Intel(R) Core(TM) */ |
| 18 /* Family (to be posted) (2012). */ | 18 /* Processor Family (to be posted) (2012). */ |
| 19 /* [4] S. Gueron: Fast GHASH computations for speeding up AES-GCM (to be */ | 19 /* [4] S. Gueron: Fast GHASH computations for speeding up AES-GCM (to be */ |
| 20 /* published) (2012). */ | 20 /* published) (2012). */ |
| 21 | 21 |
| 22 #ifndef INTEL_GCM_H | 22 #ifndef INTEL_GCM_H |
| 23 #define INTEL_GCM_H 1 | 23 #define INTEL_GCM_H 1 |
| 24 | 24 |
| 25 #include "blapii.h" | 25 #include "blapii.h" |
| 26 | 26 |
| 27 typedef struct intel_AES_GCMContextStr intel_AES_GCMContext; | 27 typedef struct intel_AES_GCMContextStr intel_AES_GCMContext; |
| 28 | 28 |
| 29 intel_AES_GCMContext *intel_AES_GCM_CreateContext(void *context, freeblCipherFun
c cipher, | 29 intel_AES_GCMContext *intel_AES_GCM_CreateContext(void *context, freeblCipherFun
c cipher, |
| 30 const unsigned char *params, unsigned int blocksize); | 30 const unsigned char *params, unsigned int blocksize); |
| 31 | 31 |
| 32 void intel_AES_GCM_DestroyContext(intel_AES_GCMContext *gcm, PRBool freeit); | 32 void intel_AES_GCM_DestroyContext(intel_AES_GCMContext *gcm, PRBool freeit); |
| 33 | 33 |
| 34 SECStatus intel_AES_GCM_EncryptUpdate(intel_AES_GCMContext *gcm, unsigned char *
outbuf, | 34 SECStatus intel_AES_GCM_EncryptUpdate(intel_AES_GCMContext *gcm, unsigned char *
outbuf, |
| 35 unsigned int *outlen, unsigned int maxout, | 35 unsigned int *outlen, unsigned int maxout, |
| 36 const unsigned char *inbuf, unsigned int inlen, | 36 const unsigned char *inbuf, unsigned int inlen, |
| 37 unsigned int blocksize); | 37 unsigned int blocksize); |
| 38 | 38 |
| 39 SECStatus intel_AES_GCM_DecryptUpdate(intel_AES_GCMContext *gcm, unsigned char *
outbuf, | 39 SECStatus intel_AES_GCM_DecryptUpdate(intel_AES_GCMContext *gcm, unsigned char *
outbuf, |
| 40 unsigned int *outlen, unsigned int maxout, | 40 unsigned int *outlen, unsigned int maxout, |
| 41 const unsigned char *inbuf, unsigned int inlen, | 41 const unsigned char *inbuf, unsigned int inlen, |
| 42 unsigned int blocksize); | 42 unsigned int blocksize); |
| 43 | 43 |
| 44 /* Prorotypes of functions in the assembler file for fast AES-GCM, using | 44 /* Prototypes of functions in the assembler file for fast AES-GCM, using |
| 45 Intel AES-NI and CLMUL-NI, as described in [1] | 45 Intel AES-NI and CLMUL-NI, as described in [1] |
| 46 [1] Shay Gueron, Michael E. Kounavis: Intel® Carry-Less Multiplication | 46 [1] Shay Gueron, Michael E. Kounavis: Intel(R) Carry-Less Multiplication |
| 47 Instruction and its Usage for Computing the GCM Mode */ | 47 Instruction and its Usage for Computing the GCM Mode */ |
| 48 | 48 |
| 49 /* Prepares the constants used in the aggregated reduction method */ | 49 /* Prepares the constants used in the aggregated reduction method */ |
| 50 void intel_aes_gcmINIT(unsigned char Htbl[16*16], | 50 void intel_aes_gcmINIT(unsigned char Htbl[16*16], |
| 51 unsigned char *KS, | 51 unsigned char *KS, |
| 52 int NR); | 52 int NR); |
| 53 | 53 |
| 54 /* Produces the final GHASH value */ | 54 /* Produces the final GHASH value */ |
| 55 void intel_aes_gcmTAG(unsigned char Htbl[16*16], | 55 void intel_aes_gcmTAG(unsigned char Htbl[16*16], |
| 56 unsigned char *Tp, | 56 unsigned char *Tp, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 74 void *Gctx, | 74 void *Gctx, |
| 75 unsigned long len); | 75 unsigned long len); |
| 76 | 76 |
| 77 /* Similar to ENC, but decrypts the Ciphertext. */ | 77 /* Similar to ENC, but decrypts the Ciphertext. */ |
| 78 void intel_aes_gcmDEC(const unsigned char* CT, | 78 void intel_aes_gcmDEC(const unsigned char* CT, |
| 79 unsigned char* PT, | 79 unsigned char* PT, |
| 80 void *Gctx, | 80 void *Gctx, |
| 81 unsigned long len); | 81 unsigned long len); |
| 82 | 82 |
| 83 #endif | 83 #endif |
| OLD | NEW |