Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: nss/lib/freebl/rijndael.c

Issue 214183004: Implement AES in different modes of operation, using AES-NI and (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss.git@master
Patch Set: Remove an assertion. ctr->cipher doesn't set *outlen. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « nss/lib/freebl/intel-gcm-x86-masm.asm ('k') | patches/nss-intel-aes-windows.patch » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 #ifdef FREEBL_NO_DEPEND 5 #ifdef FREEBL_NO_DEPEND
6 #include "stubs.h" 6 #include "stubs.h"
7 #endif 7 #endif
8 8
9 #include "prinit.h" 9 #include "prinit.h"
10 #include "prerr.h" 10 #include "prerr.h"
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 cx->Nr = RIJNDAEL_NUM_ROUNDS(Nk, cx->Nb); 1056 cx->Nr = RIJNDAEL_NUM_ROUNDS(Nk, cx->Nb);
1057 /* copy in the iv, if neccessary */ 1057 /* copy in the iv, if neccessary */
1058 if (mode == NSS_AES_CBC) { 1058 if (mode == NSS_AES_CBC) {
1059 memcpy(cx->iv, iv, blocksize); 1059 memcpy(cx->iv, iv, blocksize);
1060 #if USE_HW_AES 1060 #if USE_HW_AES
1061 if (use_hw_aes) { 1061 if (use_hw_aes) {
1062 cx->worker = (freeblCipherFunc) 1062 cx->worker = (freeblCipherFunc)
1063 intel_aes_cbc_worker(encrypt, keysize); 1063 intel_aes_cbc_worker(encrypt, keysize);
1064 } else 1064 } else
1065 #endif 1065 #endif
1066 {
1066 cx->worker = (freeblCipherFunc) (encrypt 1067 cx->worker = (freeblCipherFunc) (encrypt
1067 ? &rijndael_encryptCBC : &rijndael_decryptCBC); 1068 ? &rijndael_encryptCBC : &rijndael_decryptCBC);
1069 }
1068 } else { 1070 } else {
1069 #if USE_HW_AES 1071 #if USE_HW_AES
1070 if (use_hw_aes) { 1072 if (use_hw_aes) {
1071 cx->worker = (freeblCipherFunc) 1073 cx->worker = (freeblCipherFunc)
1072 intel_aes_ecb_worker(encrypt, keysize); 1074 intel_aes_ecb_worker(encrypt, keysize);
1073 } else 1075 } else
1074 #endif 1076 #endif
1077 {
1075 cx->worker = (freeblCipherFunc) (encrypt 1078 cx->worker = (freeblCipherFunc) (encrypt
1076 ? &rijndael_encryptECB : &rijndael_decryptECB); 1079 ? &rijndael_encryptECB : &rijndael_decryptECB);
1080 }
1077 } 1081 }
1078 PORT_Assert((cx->Nb * (cx->Nr + 1)) <= RIJNDAEL_MAX_EXP_KEY_SIZE); 1082 PORT_Assert((cx->Nb * (cx->Nr + 1)) <= RIJNDAEL_MAX_EXP_KEY_SIZE);
1079 if ((cx->Nb * (cx->Nr + 1)) > RIJNDAEL_MAX_EXP_KEY_SIZE) { 1083 if ((cx->Nb * (cx->Nr + 1)) > RIJNDAEL_MAX_EXP_KEY_SIZE) {
1080 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); 1084 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
1081 goto cleanup; 1085 goto cleanup;
1082 } 1086 }
1083 #ifdef USE_HW_AES 1087 #ifdef USE_HW_AES
1084 if (use_hw_aes) { 1088 if (use_hw_aes) {
1085 intel_aes_init(encrypt, keysize); 1089 intel_aes_init(encrypt, keysize);
1086 } else 1090 } else
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 { 1168 {
1165 cx->worker_cx = GCM_CreateContext(cx, cx->worker, iv, blocksize); 1169 cx->worker_cx = GCM_CreateContext(cx, cx->worker, iv, blocksize);
1166 cx->worker = (freeblCipherFunc) 1170 cx->worker = (freeblCipherFunc)
1167 (encrypt ? GCM_EncryptUpdate : GCM_DecryptUpdate); 1171 (encrypt ? GCM_EncryptUpdate : GCM_DecryptUpdate);
1168 cx->destroy = (freeblDestroyFunc) GCM_DestroyContext; 1172 cx->destroy = (freeblDestroyFunc) GCM_DestroyContext;
1169 cx->isBlock = PR_FALSE; 1173 cx->isBlock = PR_FALSE;
1170 } 1174 }
1171 break; 1175 break;
1172 case NSS_AES_CTR: 1176 case NSS_AES_CTR:
1173 cx->worker_cx = CTR_CreateContext(cx, cx->worker, iv, blocksize); 1177 cx->worker_cx = CTR_CreateContext(cx, cx->worker, iv, blocksize);
1174 » cx->worker = (freeblCipherFunc) CTR_Update ; 1178 #if defined(USE_HW_AES) && defined(_MSC_VER)
1179 » if (use_hw_aes) {
1180 » cx->worker = (freeblCipherFunc) CTR_Update_HW_AES;
1181 » } else
1182 #endif
1183 » {
1184 » cx->worker = (freeblCipherFunc) CTR_Update;
1185 » }
1175 cx->destroy = (freeblDestroyFunc) CTR_DestroyContext; 1186 cx->destroy = (freeblDestroyFunc) CTR_DestroyContext;
1176 cx->isBlock = PR_FALSE; 1187 cx->isBlock = PR_FALSE;
1177 break; 1188 break;
1178 default: 1189 default:
1179 /* everything has already been set up by aes_InitContext, just 1190 /* everything has already been set up by aes_InitContext, just
1180 * return */ 1191 * return */
1181 return SECSuccess; 1192 return SECSuccess;
1182 } 1193 }
1183 /* check to see if we succeeded in getting the worker context */ 1194 /* check to see if we succeeded in getting the worker context */
1184 if (cx->worker_cx == NULL) { 1195 if (cx->worker_cx == NULL) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 return SECFailure; 1295 return SECFailure;
1285 } 1296 }
1286 if (maxOutputLen < inputLen) { 1297 if (maxOutputLen < inputLen) {
1287 PORT_SetError(SEC_ERROR_OUTPUT_LEN); 1298 PORT_SetError(SEC_ERROR_OUTPUT_LEN);
1288 return SECFailure; 1299 return SECFailure;
1289 } 1300 }
1290 *outputLen = inputLen; 1301 *outputLen = inputLen;
1291 return (*cx->worker)(cx->worker_cx, output, outputLen, maxOutputLen, 1302 return (*cx->worker)(cx->worker_cx, output, outputLen, maxOutputLen,
1292 input, inputLen, blocksize); 1303 input, inputLen, blocksize);
1293 } 1304 }
OLDNEW
« no previous file with comments | « nss/lib/freebl/intel-gcm-x86-masm.asm ('k') | patches/nss-intel-aes-windows.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698