ccp-ops.c (e219aafe50fd546b8686582ddbafd24c3c2eda04) | ccp-ops.c (bdd75064d2b2068007f4fc5e26ac726e8617a090) |
---|---|
1/* 2 * AMD Cryptographic Coprocessor (CCP) driver 3 * 4 * Copyright (C) 2013 Advanced Micro Devices, Inc. 5 * 6 * Author: Tom Lendacky <thomas.lendacky@amd.com> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 138 unchanged lines hidden (view full) --- 147 148static const __be32 ccp_sha256_init[CCP_SHA_CTXSIZE / sizeof(__be32)] = { 149 cpu_to_be32(SHA256_H0), cpu_to_be32(SHA256_H1), 150 cpu_to_be32(SHA256_H2), cpu_to_be32(SHA256_H3), 151 cpu_to_be32(SHA256_H4), cpu_to_be32(SHA256_H5), 152 cpu_to_be32(SHA256_H6), cpu_to_be32(SHA256_H7), 153}; 154 | 1/* 2 * AMD Cryptographic Coprocessor (CCP) driver 3 * 4 * Copyright (C) 2013 Advanced Micro Devices, Inc. 5 * 6 * Author: Tom Lendacky <thomas.lendacky@amd.com> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 138 unchanged lines hidden (view full) --- 147 148static const __be32 ccp_sha256_init[CCP_SHA_CTXSIZE / sizeof(__be32)] = { 149 cpu_to_be32(SHA256_H0), cpu_to_be32(SHA256_H1), 150 cpu_to_be32(SHA256_H2), cpu_to_be32(SHA256_H3), 151 cpu_to_be32(SHA256_H4), cpu_to_be32(SHA256_H5), 152 cpu_to_be32(SHA256_H6), cpu_to_be32(SHA256_H7), 153}; 154 |
155/* The CCP cannot perform zero-length sha operations so the caller 156 * is required to buffer data for the final operation. However, a 157 * sha operation for a message with a total length of zero is valid 158 * so known values are required to supply the result. 159 */ 160static const u8 ccp_sha1_zero[CCP_SHA_CTXSIZE] = { 161 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 162 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 163 0xaf, 0xd8, 0x07, 0x09, 0x00, 0x00, 0x00, 0x00, 164 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 165}; 166 167static const u8 ccp_sha224_zero[CCP_SHA_CTXSIZE] = { 168 0xd1, 0x4a, 0x02, 0x8c, 0x2a, 0x3a, 0x2b, 0xc9, 169 0x47, 0x61, 0x02, 0xbb, 0x28, 0x82, 0x34, 0xc4, 170 0x15, 0xa2, 0xb0, 0x1f, 0x82, 0x8e, 0xa6, 0x2a, 171 0xc5, 0xb3, 0xe4, 0x2f, 0x00, 0x00, 0x00, 0x00, 172}; 173 174static const u8 ccp_sha256_zero[CCP_SHA_CTXSIZE] = { 175 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 176 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 177 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 178 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55, 179}; 180 | |
181static u32 ccp_addr_lo(struct ccp_dma_info *info) 182{ 183 return lower_32_bits(info->address + info->offset); 184} 185 186static u32 ccp_addr_hi(struct ccp_dma_info *info) 187{ 188 return upper_32_bits(info->address + info->offset) & 0x0000ffff; --- 1197 unchanged lines hidden (view full) --- 1386 return 0; 1387 1388 /* CCP can't do a zero length sha operation so the caller 1389 * must buffer the data. 1390 */ 1391 if (sha->msg_bits) 1392 return -EINVAL; 1393 | 155static u32 ccp_addr_lo(struct ccp_dma_info *info) 156{ 157 return lower_32_bits(info->address + info->offset); 158} 159 160static u32 ccp_addr_hi(struct ccp_dma_info *info) 161{ 162 return upper_32_bits(info->address + info->offset) & 0x0000ffff; --- 1197 unchanged lines hidden (view full) --- 1360 return 0; 1361 1362 /* CCP can't do a zero length sha operation so the caller 1363 * must buffer the data. 1364 */ 1365 if (sha->msg_bits) 1366 return -EINVAL; 1367 |
1394 /* A sha operation for a message with a total length of zero, 1395 * return known result. | 1368 /* The CCP cannot perform zero-length sha operations so the 1369 * caller is required to buffer data for the final operation. 1370 * However, a sha operation for a message with a total length 1371 * of zero is valid so known values are required to supply 1372 * the result. |
1396 */ 1397 switch (sha->type) { 1398 case CCP_SHA_TYPE_1: | 1373 */ 1374 switch (sha->type) { 1375 case CCP_SHA_TYPE_1: |
1399 sha_zero = ccp_sha1_zero; | 1376 sha_zero = sha1_zero_message_hash; |
1400 break; 1401 case CCP_SHA_TYPE_224: | 1377 break; 1378 case CCP_SHA_TYPE_224: |
1402 sha_zero = ccp_sha224_zero; | 1379 sha_zero = sha224_zero_message_hash; |
1403 break; 1404 case CCP_SHA_TYPE_256: | 1380 break; 1381 case CCP_SHA_TYPE_256: |
1405 sha_zero = ccp_sha256_zero; | 1382 sha_zero = sha256_zero_message_hash; |
1406 break; 1407 default: 1408 return -EINVAL; 1409 } 1410 1411 scatterwalk_map_and_copy((void *)sha_zero, sha->ctx, 0, 1412 sha->ctx_len, 1); 1413 --- 744 unchanged lines hidden --- | 1383 break; 1384 default: 1385 return -EINVAL; 1386 } 1387 1388 scatterwalk_map_and_copy((void *)sha_zero, sha->ctx, 0, 1389 sha->ctx_len, 1); 1390 --- 744 unchanged lines hidden --- |