forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto: ccp - CCP versioning support
Future hardware may introduce new algorithms wherein the driver will need to manage resources for different versions of the cryptographic coprocessor. This precursor patch determines the version of the available device, and marks and registers algorithms accordingly. A structure is added which manages the version-specific data. Signed-off-by: Gary R Hook <[email protected]> Acked-by: Tom Lendacky <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
- Loading branch information
Showing
7 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* AMD Cryptographic Coprocessor (CCP) AES crypto API support | ||
* | ||
* Copyright (C) 2013 Advanced Micro Devices, Inc. | ||
* Copyright (C) 2013,2016 Advanced Micro Devices, Inc. | ||
* | ||
* Author: Tom Lendacky <[email protected]> | ||
* | ||
|
@@ -259,6 +259,7 @@ static struct crypto_alg ccp_aes_rfc3686_defaults = { | |
|
||
struct ccp_aes_def { | ||
enum ccp_aes_mode mode; | ||
unsigned int version; | ||
const char *name; | ||
const char *driver_name; | ||
unsigned int blocksize; | ||
|
@@ -269,6 +270,7 @@ struct ccp_aes_def { | |
static struct ccp_aes_def aes_algs[] = { | ||
{ | ||
.mode = CCP_AES_MODE_ECB, | ||
.version = CCP_VERSION(3, 0), | ||
.name = "ecb(aes)", | ||
.driver_name = "ecb-aes-ccp", | ||
.blocksize = AES_BLOCK_SIZE, | ||
|
@@ -277,6 +279,7 @@ static struct ccp_aes_def aes_algs[] = { | |
}, | ||
{ | ||
.mode = CCP_AES_MODE_CBC, | ||
.version = CCP_VERSION(3, 0), | ||
.name = "cbc(aes)", | ||
.driver_name = "cbc-aes-ccp", | ||
.blocksize = AES_BLOCK_SIZE, | ||
|
@@ -285,6 +288,7 @@ static struct ccp_aes_def aes_algs[] = { | |
}, | ||
{ | ||
.mode = CCP_AES_MODE_CFB, | ||
.version = CCP_VERSION(3, 0), | ||
.name = "cfb(aes)", | ||
.driver_name = "cfb-aes-ccp", | ||
.blocksize = AES_BLOCK_SIZE, | ||
|
@@ -293,6 +297,7 @@ static struct ccp_aes_def aes_algs[] = { | |
}, | ||
{ | ||
.mode = CCP_AES_MODE_OFB, | ||
.version = CCP_VERSION(3, 0), | ||
.name = "ofb(aes)", | ||
.driver_name = "ofb-aes-ccp", | ||
.blocksize = 1, | ||
|
@@ -301,6 +306,7 @@ static struct ccp_aes_def aes_algs[] = { | |
}, | ||
{ | ||
.mode = CCP_AES_MODE_CTR, | ||
.version = CCP_VERSION(3, 0), | ||
.name = "ctr(aes)", | ||
.driver_name = "ctr-aes-ccp", | ||
.blocksize = 1, | ||
|
@@ -309,6 +315,7 @@ static struct ccp_aes_def aes_algs[] = { | |
}, | ||
{ | ||
.mode = CCP_AES_MODE_CTR, | ||
.version = CCP_VERSION(3, 0), | ||
.name = "rfc3686(ctr(aes))", | ||
.driver_name = "rfc3686-ctr-aes-ccp", | ||
.blocksize = 1, | ||
|
@@ -357,8 +364,11 @@ static int ccp_register_aes_alg(struct list_head *head, | |
int ccp_register_aes_algs(struct list_head *head) | ||
{ | ||
int i, ret; | ||
unsigned int ccpversion = ccp_version(); | ||
|
||
for (i = 0; i < ARRAY_SIZE(aes_algs); i++) { | ||
if (aes_algs[i].version > ccpversion) | ||
continue; | ||
ret = ccp_register_aes_alg(head, &aes_algs[i]); | ||
if (ret) | ||
return ret; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* AMD Cryptographic Coprocessor (CCP) SHA crypto API support | ||
* | ||
* Copyright (C) 2013 Advanced Micro Devices, Inc. | ||
* Copyright (C) 2013,2016 Advanced Micro Devices, Inc. | ||
* | ||
* Author: Tom Lendacky <[email protected]> | ||
* | ||
|
@@ -341,6 +341,7 @@ static void ccp_hmac_sha_cra_exit(struct crypto_tfm *tfm) | |
} | ||
|
||
struct ccp_sha_def { | ||
unsigned int version; | ||
const char *name; | ||
const char *drv_name; | ||
enum ccp_sha_type type; | ||
|
@@ -350,20 +351,23 @@ struct ccp_sha_def { | |
|
||
static struct ccp_sha_def sha_algs[] = { | ||
{ | ||
.version = CCP_VERSION(3, 0), | ||
.name = "sha1", | ||
.drv_name = "sha1-ccp", | ||
.type = CCP_SHA_TYPE_1, | ||
.digest_size = SHA1_DIGEST_SIZE, | ||
.block_size = SHA1_BLOCK_SIZE, | ||
}, | ||
{ | ||
.version = CCP_VERSION(3, 0), | ||
.name = "sha224", | ||
.drv_name = "sha224-ccp", | ||
.type = CCP_SHA_TYPE_224, | ||
.digest_size = SHA224_DIGEST_SIZE, | ||
.block_size = SHA224_BLOCK_SIZE, | ||
}, | ||
{ | ||
.version = CCP_VERSION(3, 0), | ||
.name = "sha256", | ||
.drv_name = "sha256-ccp", | ||
.type = CCP_SHA_TYPE_256, | ||
|
@@ -480,8 +484,11 @@ static int ccp_register_sha_alg(struct list_head *head, | |
int ccp_register_sha_algs(struct list_head *head) | ||
{ | ||
int i, ret; | ||
unsigned int ccpversion = ccp_version(); | ||
|
||
for (i = 0; i < ARRAY_SIZE(sha_algs); i++) { | ||
if (sha_algs[i].version > ccpversion) | ||
continue; | ||
ret = ccp_register_sha_alg(head, &sha_algs[i]); | ||
if (ret) | ||
return ret; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters