diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-23 00:04:48 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-23 00:04:48 -0400 |
| commit | 44d21c3f3a2ef2f58b18bda64c52c99e723f3f4a (patch) | |
| tree | 5146cf96cb0dbd7121176d484417ab942c92dcd4 /include/linux | |
| parent | efdfce2b7ff3205ba0fba10270b92b80bbc6187d (diff) | |
| parent | fe55dfdcdfabf160ab0c14617725c57c7a1facfc (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu:
"Here is the crypto update for 4.2:
API:
- Convert RNG interface to new style.
- New AEAD interface with one SG list for AD and plain/cipher text.
All external AEAD users have been converted.
- New asymmetric key interface (akcipher).
Algorithms:
- Chacha20, Poly1305 and RFC7539 support.
- New RSA implementation.
- Jitter RNG.
- DRBG is now seeded with both /dev/random and Jitter RNG. If kernel
pool isn't ready then DRBG will be reseeded when it is.
- DRBG is now the default crypto API RNG, replacing krng.
- 842 compression (previously part of powerpc nx driver).
Drivers:
- Accelerated SHA-512 for arm64.
- New Marvell CESA driver that supports DMA and more algorithms.
- Updated powerpc nx 842 support.
- Added support for SEC1 hardware to talitos"
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (292 commits)
crypto: marvell/cesa - remove COMPILE_TEST dependency
crypto: algif_aead - Temporarily disable all AEAD algorithms
crypto: af_alg - Forbid the use internal algorithms
crypto: echainiv - Only hold RNG during initialisation
crypto: seqiv - Add compatibility support without RNG
crypto: eseqiv - Offer normal cipher functionality without RNG
crypto: chainiv - Offer normal cipher functionality without RNG
crypto: user - Add CRYPTO_MSG_DELRNG
crypto: user - Move cryptouser.h to uapi
crypto: rng - Do not free default RNG when it becomes unused
crypto: skcipher - Allow givencrypt to be NULL
crypto: sahara - propagate the error on clk_disable_unprepare() failure
crypto: rsa - fix invalid select for AKCIPHER
crypto: picoxcell - Update to the current clk API
crypto: nx - Check for bogus firmware properties
crypto: marvell/cesa - add DT bindings documentation
crypto: marvell/cesa - add support for Kirkwood and Dove SoCs
crypto: marvell/cesa - add support for Orion SoCs
crypto: marvell/cesa - add allhwsupport module parameter
crypto: marvell/cesa - add support for all armada SoCs
...
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/crypto.h | 501 | ||||
| -rw-r--r-- | include/linux/cryptouser.h | 105 | ||||
| -rw-r--r-- | include/linux/mbus.h | 5 | ||||
| -rw-r--r-- | include/linux/module.h | 12 | ||||
| -rw-r--r-- | include/linux/mpi.h | 15 | ||||
| -rw-r--r-- | include/linux/nx842.h | 11 | ||||
| -rw-r--r-- | include/linux/random.h | 9 | ||||
| -rw-r--r-- | include/linux/scatterlist.h | 1 | ||||
| -rw-r--r-- | include/linux/sw842.h | 12 |
9 files changed, 67 insertions, 604 deletions
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 10df5d2d093a..81ef938b0a8e 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h | |||
| @@ -53,6 +53,7 @@ | |||
| 53 | #define CRYPTO_ALG_TYPE_SHASH 0x00000009 | 53 | #define CRYPTO_ALG_TYPE_SHASH 0x00000009 |
| 54 | #define CRYPTO_ALG_TYPE_AHASH 0x0000000a | 54 | #define CRYPTO_ALG_TYPE_AHASH 0x0000000a |
| 55 | #define CRYPTO_ALG_TYPE_RNG 0x0000000c | 55 | #define CRYPTO_ALG_TYPE_RNG 0x0000000c |
| 56 | #define CRYPTO_ALG_TYPE_AKCIPHER 0x0000000d | ||
| 56 | #define CRYPTO_ALG_TYPE_PCOMPRESS 0x0000000f | 57 | #define CRYPTO_ALG_TYPE_PCOMPRESS 0x0000000f |
| 57 | 58 | ||
| 58 | #define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e | 59 | #define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e |
| @@ -101,6 +102,12 @@ | |||
| 101 | #define CRYPTO_ALG_INTERNAL 0x00002000 | 102 | #define CRYPTO_ALG_INTERNAL 0x00002000 |
| 102 | 103 | ||
| 103 | /* | 104 | /* |
| 105 | * Temporary flag used to prevent legacy AEAD implementations from | ||
| 106 | * being used by user-space. | ||
| 107 | */ | ||
| 108 | #define CRYPTO_ALG_AEAD_NEW 0x00004000 | ||
| 109 | |||
| 110 | /* | ||
| 104 | * Transform masks and values (for crt_flags). | 111 | * Transform masks and values (for crt_flags). |
| 105 | */ | 112 | */ |
| 106 | #define CRYPTO_TFM_REQ_MASK 0x000fff00 | 113 | #define CRYPTO_TFM_REQ_MASK 0x000fff00 |
| @@ -138,9 +145,9 @@ struct crypto_async_request; | |||
| 138 | struct crypto_aead; | 145 | struct crypto_aead; |
| 139 | struct crypto_blkcipher; | 146 | struct crypto_blkcipher; |
| 140 | struct crypto_hash; | 147 | struct crypto_hash; |
| 141 | struct crypto_rng; | ||
| 142 | struct crypto_tfm; | 148 | struct crypto_tfm; |
| 143 | struct crypto_type; | 149 | struct crypto_type; |
| 150 | struct aead_request; | ||
| 144 | struct aead_givcrypt_request; | 151 | struct aead_givcrypt_request; |
| 145 | struct skcipher_givcrypt_request; | 152 | struct skcipher_givcrypt_request; |
| 146 | 153 | ||
| @@ -175,32 +182,6 @@ struct ablkcipher_request { | |||
| 175 | void *__ctx[] CRYPTO_MINALIGN_ATTR; | 182 | void *__ctx[] CRYPTO_MINALIGN_ATTR; |
| 176 | }; | 183 | }; |
| 177 | 184 | ||
| 178 | /** | ||
| 179 | * struct aead_request - AEAD request | ||
| 180 | * @base: Common attributes for async crypto requests | ||
| 181 | * @assoclen: Length in bytes of associated data for authentication | ||
| 182 | * @cryptlen: Length of data to be encrypted or decrypted | ||
| 183 | * @iv: Initialisation vector | ||
| 184 | * @assoc: Associated data | ||
| 185 | * @src: Source data | ||
| 186 | * @dst: Destination data | ||
| 187 | * @__ctx: Start of private context data | ||
| 188 | */ | ||
| 189 | struct aead_request { | ||
| 190 | struct crypto_async_request base; | ||
| 191 | |||
| 192 | unsigned int assoclen; | ||
| 193 | unsigned int cryptlen; | ||
| 194 | |||
| 195 | u8 *iv; | ||
| 196 | |||
| 197 | struct scatterlist *assoc; | ||
| 198 | struct scatterlist *src; | ||
| 199 | struct scatterlist *dst; | ||
| 200 | |||
| 201 | void *__ctx[] CRYPTO_MINALIGN_ATTR; | ||
| 202 | }; | ||
| 203 | |||
| 204 | struct blkcipher_desc { | 185 | struct blkcipher_desc { |
| 205 | struct crypto_blkcipher *tfm; | 186 | struct crypto_blkcipher *tfm; |
| 206 | void *info; | 187 | void *info; |
| @@ -294,7 +275,7 @@ struct ablkcipher_alg { | |||
| 294 | }; | 275 | }; |
| 295 | 276 | ||
| 296 | /** | 277 | /** |
| 297 | * struct aead_alg - AEAD cipher definition | 278 | * struct old_aead_alg - AEAD cipher definition |
| 298 | * @maxauthsize: Set the maximum authentication tag size supported by the | 279 | * @maxauthsize: Set the maximum authentication tag size supported by the |
| 299 | * transformation. A transformation may support smaller tag sizes. | 280 | * transformation. A transformation may support smaller tag sizes. |
| 300 | * As the authentication tag is a message digest to ensure the | 281 | * As the authentication tag is a message digest to ensure the |
| @@ -319,7 +300,7 @@ struct ablkcipher_alg { | |||
| 319 | * All fields except @givencrypt , @givdecrypt , @geniv and @ivsize are | 300 | * All fields except @givencrypt , @givdecrypt , @geniv and @ivsize are |
| 320 | * mandatory and must be filled. | 301 | * mandatory and must be filled. |
| 321 | */ | 302 | */ |
| 322 | struct aead_alg { | 303 | struct old_aead_alg { |
| 323 | int (*setkey)(struct crypto_aead *tfm, const u8 *key, | 304 | int (*setkey)(struct crypto_aead *tfm, const u8 *key, |
| 324 | unsigned int keylen); | 305 | unsigned int keylen); |
| 325 | int (*setauthsize)(struct crypto_aead *tfm, unsigned int authsize); | 306 | int (*setauthsize)(struct crypto_aead *tfm, unsigned int authsize); |
| @@ -426,40 +407,12 @@ struct compress_alg { | |||
| 426 | unsigned int slen, u8 *dst, unsigned int *dlen); | 407 | unsigned int slen, u8 *dst, unsigned int *dlen); |
| 427 | }; | 408 | }; |
| 428 | 409 | ||
| 429 | /** | ||
| 430 | * struct rng_alg - random number generator definition | ||
| 431 | * @rng_make_random: The function defined by this variable obtains a random | ||
| 432 | * number. The random number generator transform must generate | ||
| 433 | * the random number out of the context provided with this | ||
| 434 | * call. | ||
| 435 | * @rng_reset: Reset of the random number generator by clearing the entire state. | ||
| 436 | * With the invocation of this function call, the random number | ||
| 437 | * generator shall completely reinitialize its state. If the random | ||
| 438 | * number generator requires a seed for setting up a new state, | ||
| 439 | * the seed must be provided by the consumer while invoking this | ||
| 440 | * function. The required size of the seed is defined with | ||
| 441 | * @seedsize . | ||
| 442 | * @seedsize: The seed size required for a random number generator | ||
| 443 | * initialization defined with this variable. Some random number | ||
| 444 | * generators like the SP800-90A DRBG does not require a seed as the | ||
| 445 | * seeding is implemented internally without the need of support by | ||
| 446 | * the consumer. In this case, the seed size is set to zero. | ||
| 447 | */ | ||
| 448 | struct rng_alg { | ||
| 449 | int (*rng_make_random)(struct crypto_rng *tfm, u8 *rdata, | ||
| 450 | unsigned int dlen); | ||
| 451 | int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen); | ||
| 452 | |||
| 453 | unsigned int seedsize; | ||
| 454 | }; | ||
| 455 | |||
| 456 | 410 | ||
| 457 | #define cra_ablkcipher cra_u.ablkcipher | 411 | #define cra_ablkcipher cra_u.ablkcipher |
| 458 | #define cra_aead cra_u.aead | 412 | #define cra_aead cra_u.aead |
| 459 | #define cra_blkcipher cra_u.blkcipher | 413 | #define cra_blkcipher cra_u.blkcipher |
| 460 | #define cra_cipher cra_u.cipher | 414 | #define cra_cipher cra_u.cipher |
| 461 | #define cra_compress cra_u.compress | 415 | #define cra_compress cra_u.compress |
| 462 | #define cra_rng cra_u.rng | ||
| 463 | 416 | ||
| 464 | /** | 417 | /** |
| 465 | * struct crypto_alg - definition of a cryptograpic cipher algorithm | 418 | * struct crypto_alg - definition of a cryptograpic cipher algorithm |
| @@ -505,7 +458,7 @@ struct rng_alg { | |||
| 505 | * transformation algorithm. | 458 | * transformation algorithm. |
| 506 | * @cra_type: Type of the cryptographic transformation. This is a pointer to | 459 | * @cra_type: Type of the cryptographic transformation. This is a pointer to |
| 507 | * struct crypto_type, which implements callbacks common for all | 460 | * struct crypto_type, which implements callbacks common for all |
| 508 | * trasnformation types. There are multiple options: | 461 | * transformation types. There are multiple options: |
| 509 | * &crypto_blkcipher_type, &crypto_ablkcipher_type, | 462 | * &crypto_blkcipher_type, &crypto_ablkcipher_type, |
| 510 | * &crypto_ahash_type, &crypto_aead_type, &crypto_rng_type. | 463 | * &crypto_ahash_type, &crypto_aead_type, &crypto_rng_type. |
| 511 | * This field might be empty. In that case, there are no common | 464 | * This field might be empty. In that case, there are no common |
| @@ -555,11 +508,10 @@ struct crypto_alg { | |||
| 555 | 508 | ||
| 556 | union { | 509 | union { |
| 557 | struct ablkcipher_alg ablkcipher; | 510 | struct ablkcipher_alg ablkcipher; |
| 558 | struct aead_alg aead; | 511 | struct old_aead_alg aead; |
| 559 | struct blkcipher_alg blkcipher; | 512 | struct blkcipher_alg blkcipher; |
| 560 | struct cipher_alg cipher; | 513 | struct cipher_alg cipher; |
| 561 | struct compress_alg compress; | 514 | struct compress_alg compress; |
| 562 | struct rng_alg rng; | ||
| 563 | } cra_u; | 515 | } cra_u; |
| 564 | 516 | ||
| 565 | int (*cra_init)(struct crypto_tfm *tfm); | 517 | int (*cra_init)(struct crypto_tfm *tfm); |
| @@ -567,7 +519,7 @@ struct crypto_alg { | |||
| 567 | void (*cra_destroy)(struct crypto_alg *alg); | 519 | void (*cra_destroy)(struct crypto_alg *alg); |
| 568 | 520 | ||
| 569 | struct module *cra_module; | 521 | struct module *cra_module; |
| 570 | }; | 522 | } CRYPTO_MINALIGN_ATTR; |
| 571 | 523 | ||
| 572 | /* | 524 | /* |
| 573 | * Algorithm registration interface. | 525 | * Algorithm registration interface. |
| @@ -602,21 +554,6 @@ struct ablkcipher_tfm { | |||
| 602 | unsigned int reqsize; | 554 | unsigned int reqsize; |
| 603 | }; | 555 | }; |
| 604 | 556 | ||
| 605 | struct aead_tfm { | ||
| 606 | int (*setkey)(struct crypto_aead *tfm, const u8 *key, | ||
| 607 | unsigned int keylen); | ||
| 608 | int (*encrypt)(struct aead_request *req); | ||
| 609 | int (*decrypt)(struct aead_request *req); | ||
| 610 | int (*givencrypt)(struct aead_givcrypt_request *req); | ||
| 611 | int (*givdecrypt)(struct aead_givcrypt_request *req); | ||
| 612 | |||
| 613 | struct crypto_aead *base; | ||
| 614 | |||
| 615 | unsigned int ivsize; | ||
| 616 | unsigned int authsize; | ||
| 617 | unsigned int reqsize; | ||
| 618 | }; | ||
| 619 | |||
| 620 | struct blkcipher_tfm { | 557 | struct blkcipher_tfm { |
| 621 | void *iv; | 558 | void *iv; |
| 622 | int (*setkey)(struct crypto_tfm *tfm, const u8 *key, | 559 | int (*setkey)(struct crypto_tfm *tfm, const u8 *key, |
| @@ -655,19 +592,11 @@ struct compress_tfm { | |||
| 655 | u8 *dst, unsigned int *dlen); | 592 | u8 *dst, unsigned int *dlen); |
| 656 | }; | 593 | }; |
| 657 | 594 | ||
| 658 | struct rng_tfm { | ||
| 659 | int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata, | ||
| 660 | unsigned int dlen); | ||
| 661 | int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen); | ||
| 662 | }; | ||
| 663 | |||
| 664 | #define crt_ablkcipher crt_u.ablkcipher | 595 | #define crt_ablkcipher crt_u.ablkcipher |
| 665 | #define crt_aead crt_u.aead | ||
| 666 | #define crt_blkcipher crt_u.blkcipher | 596 | #define crt_blkcipher crt_u.blkcipher |
| 667 | #define crt_cipher crt_u.cipher | 597 | #define crt_cipher crt_u.cipher |
| 668 | #define crt_hash crt_u.hash | 598 | #define crt_hash crt_u.hash |
| 669 | #define crt_compress crt_u.compress | 599 | #define crt_compress crt_u.compress |
| 670 | #define crt_rng crt_u.rng | ||
| 671 | 600 | ||
| 672 | struct crypto_tfm { | 601 | struct crypto_tfm { |
| 673 | 602 | ||
| @@ -675,12 +604,10 @@ struct crypto_tfm { | |||
| 675 | 604 | ||
| 676 | union { | 605 | union { |
| 677 | struct ablkcipher_tfm ablkcipher; | 606 | struct ablkcipher_tfm ablkcipher; |
| 678 | struct aead_tfm aead; | ||
| 679 | struct blkcipher_tfm blkcipher; | 607 | struct blkcipher_tfm blkcipher; |
| 680 | struct cipher_tfm cipher; | 608 | struct cipher_tfm cipher; |
| 681 | struct hash_tfm hash; | 609 | struct hash_tfm hash; |
| 682 | struct compress_tfm compress; | 610 | struct compress_tfm compress; |
| 683 | struct rng_tfm rng; | ||
| 684 | } crt_u; | 611 | } crt_u; |
| 685 | 612 | ||
| 686 | void (*exit)(struct crypto_tfm *tfm); | 613 | void (*exit)(struct crypto_tfm *tfm); |
| @@ -694,10 +621,6 @@ struct crypto_ablkcipher { | |||
| 694 | struct crypto_tfm base; | 621 | struct crypto_tfm base; |
| 695 | }; | 622 | }; |
| 696 | 623 | ||
| 697 | struct crypto_aead { | ||
| 698 | struct crypto_tfm base; | ||
| 699 | }; | ||
| 700 | |||
| 701 | struct crypto_blkcipher { | 624 | struct crypto_blkcipher { |
| 702 | struct crypto_tfm base; | 625 | struct crypto_tfm base; |
| 703 | }; | 626 | }; |
| @@ -714,10 +637,6 @@ struct crypto_hash { | |||
| 714 | struct crypto_tfm base; | 637 | struct crypto_tfm base; |
| 715 | }; | 638 | }; |
| 716 | 639 | ||
| 717 | struct crypto_rng { | ||
| 718 | struct crypto_tfm base; | ||
| 719 | }; | ||
| 720 | |||
| 721 | enum { | 640 | enum { |
| 722 | CRYPTOA_UNSPEC, | 641 | CRYPTOA_UNSPEC, |
| 723 | CRYPTOA_ALG, | 642 | CRYPTOA_ALG, |
| @@ -1194,400 +1113,6 @@ static inline void ablkcipher_request_set_crypt( | |||
| 1194 | } | 1113 | } |
| 1195 | 1114 | ||
| 1196 | /** | 1115 | /** |
| 1197 | * DOC: Authenticated Encryption With Associated Data (AEAD) Cipher API | ||
| 1198 | * | ||
| 1199 | * The AEAD cipher API is used with the ciphers of type CRYPTO_ALG_TYPE_AEAD | ||
| 1200 | * (listed as type "aead" in /proc/crypto) | ||
| 1201 | * | ||
| 1202 | * The most prominent examples for this type of encryption is GCM and CCM. | ||
| 1203 | * However, the kernel supports other types of AEAD ciphers which are defined | ||
| 1204 | * with the following cipher string: | ||
| 1205 | * | ||
| 1206 | * authenc(keyed message digest, block cipher) | ||
| 1207 | * | ||
| 1208 | * For example: authenc(hmac(sha256), cbc(aes)) | ||
| 1209 | * | ||
| 1210 | * The example code provided for the asynchronous block cipher operation | ||
| 1211 | * applies here as well. Naturally all *ablkcipher* symbols must be exchanged | ||
| 1212 | * the *aead* pendants discussed in the following. In addtion, for the AEAD | ||
| 1213 | * operation, the aead_request_set_assoc function must be used to set the | ||
| 1214 | * pointer to the associated data memory location before performing the | ||
| 1215 | * encryption or decryption operation. In case of an encryption, the associated | ||
| 1216 | * data memory is filled during the encryption operation. For decryption, the | ||
| 1217 | * associated data memory must contain data that is used to verify the integrity | ||
| 1218 | * of the decrypted data. Another deviation from the asynchronous block cipher | ||
| 1219 | * operation is that the caller should explicitly check for -EBADMSG of the | ||
| 1220 | * crypto_aead_decrypt. That error indicates an authentication error, i.e. | ||
| 1221 | * a breach in the integrity of the message. In essence, that -EBADMSG error | ||
| 1222 | * code is the key bonus an AEAD cipher has over "standard" block chaining | ||
| 1223 | * modes. | ||
| 1224 | */ | ||
| 1225 | |||
| 1226 | static inline struct crypto_aead *__crypto_aead_cast(struct crypto_tfm *tfm) | ||
| 1227 | { | ||
| 1228 | return (struct crypto_aead *)tfm; | ||
| 1229 | } | ||
| 1230 | |||
| 1231 | /** | ||
| 1232 | * crypto_alloc_aead() - allocate AEAD cipher handle | ||
| 1233 | * @alg_name: is the cra_name / name or cra_driver_name / driver name of the | ||
| 1234 | * AEAD cipher | ||
| 1235 | * @type: specifies the type of the cipher | ||
| 1236 | * @mask: specifies the mask for the cipher | ||
| 1237 | * | ||
| 1238 | * Allocate a cipher handle for an AEAD. The returned struct | ||
| 1239 | * crypto_aead is the cipher handle that is required for any subsequent | ||
| 1240 | * API invocation for that AEAD. | ||
| 1241 | * | ||
| 1242 | * Return: allocated cipher handle in case of success; IS_ERR() is true in case | ||
| 1243 | * of an error, PTR_ERR() returns the error code. | ||
| 1244 | */ | ||
| 1245 | struct crypto_aead *crypto_alloc_aead(const char *alg_name, u32 type, u32 mask); | ||
| 1246 | |||
| 1247 | static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm) | ||
| 1248 | { | ||
| 1249 | return &tfm->base; | ||
| 1250 | } | ||
| 1251 | |||
| 1252 | /** | ||
| 1253 | * crypto_free_aead() - zeroize and free aead handle | ||
| 1254 | * @tfm: cipher handle to be freed | ||
| 1255 | */ | ||
| 1256 | static inline void crypto_free_aead(struct crypto_aead *tfm) | ||
| 1257 | { | ||
| 1258 | crypto_free_tfm(crypto_aead_tfm(tfm)); | ||
| 1259 | } | ||
| 1260 | |||
| 1261 | static inline struct aead_tfm *crypto_aead_crt(struct crypto_aead *tfm) | ||
| 1262 | { | ||
| 1263 | return &crypto_aead_tfm(tfm)->crt_aead; | ||
| 1264 | } | ||
| 1265 | |||
| 1266 | /** | ||
| 1267 | * crypto_aead_ivsize() - obtain IV size | ||
| 1268 | * @tfm: cipher handle | ||
| 1269 | * | ||
| 1270 | * The size of the IV for the aead referenced by the cipher handle is | ||
| 1271 | * returned. This IV size may be zero if the cipher does not need an IV. | ||
| 1272 | * | ||
| 1273 | * Return: IV size in bytes | ||
| 1274 | */ | ||
| 1275 | static inline unsigned int crypto_aead_ivsize(struct crypto_aead *tfm) | ||
| 1276 | { | ||
| 1277 | return crypto_aead_crt(tfm)->ivsize; | ||
| 1278 | } | ||
| 1279 | |||
| 1280 | /** | ||
| 1281 | * crypto_aead_authsize() - obtain maximum authentication data size | ||
| 1282 | * @tfm: cipher handle | ||
| 1283 | * | ||
| 1284 | * The maximum size of the authentication data for the AEAD cipher referenced | ||
| 1285 | * by the AEAD cipher handle is returned. The authentication data size may be | ||
| 1286 | * zero if the cipher implements a hard-coded maximum. | ||
| 1287 | * | ||
| 1288 | * The authentication data may also be known as "tag value". | ||
| 1289 | * | ||
| 1290 | * Return: authentication data size / tag size in bytes | ||
| 1291 | */ | ||
| 1292 | static inline unsigned int crypto_aead_authsize(struct crypto_aead *tfm) | ||
| 1293 | { | ||
| 1294 | return crypto_aead_crt(tfm)->authsize; | ||
| 1295 | } | ||
| 1296 | |||
| 1297 | /** | ||
| 1298 | * crypto_aead_blocksize() - obtain block size of cipher | ||
| 1299 | * @tfm: cipher handle | ||
| 1300 | * | ||
| 1301 | * The block size for the AEAD referenced with the cipher handle is returned. | ||
| 1302 | * The caller may use that information to allocate appropriate memory for the | ||
| 1303 | * data returned by the encryption or decryption operation | ||
| 1304 | * | ||
| 1305 | * Return: block size of cipher | ||
| 1306 | */ | ||
| 1307 | static inline unsigned int crypto_aead_blocksize(struct crypto_aead *tfm) | ||
| 1308 | { | ||
| 1309 | return crypto_tfm_alg_blocksize(crypto_aead_tfm(tfm)); | ||
| 1310 | } | ||
| 1311 | |||
| 1312 | static inline unsigned int crypto_aead_alignmask(struct crypto_aead *tfm) | ||
| 1313 | { | ||
| 1314 | return crypto_tfm_alg_alignmask(crypto_aead_tfm(tfm)); | ||
| 1315 | } | ||
| 1316 | |||
| 1317 | static inline u32 crypto_aead_get_flags(struct crypto_aead *tfm) | ||
| 1318 | { | ||
| 1319 | return crypto_tfm_get_flags(crypto_aead_tfm(tfm)); | ||
| 1320 | } | ||
| 1321 | |||
| 1322 | static inline void crypto_aead_set_flags(struct crypto_aead *tfm, u32 flags) | ||
| 1323 | { | ||
| 1324 | crypto_tfm_set_flags(crypto_aead_tfm(tfm), flags); | ||
| 1325 | } | ||
| 1326 | |||
| 1327 | static inline void crypto_aead_clear_flags(struct crypto_aead *tfm, u32 flags) | ||
| 1328 | { | ||
| 1329 | crypto_tfm_clear_flags(crypto_aead_tfm(tfm), flags); | ||
| 1330 | } | ||
| 1331 | |||
| 1332 | /** | ||
| 1333 | * crypto_aead_setkey() - set key for cipher | ||
| 1334 | * @tfm: cipher handle | ||
| 1335 | * @key: buffer holding the key | ||
| 1336 | * @keylen: length of the key in bytes | ||
| 1337 | * | ||
| 1338 | * The caller provided key is set for the AEAD referenced by the cipher | ||
| 1339 | * handle. | ||
| 1340 | * | ||
| 1341 | * Note, the key length determines the cipher type. Many block ciphers implement | ||
| 1342 | * different cipher modes depending on the key size, such as AES-128 vs AES-192 | ||
| 1343 | * vs. AES-256. When providing a 16 byte key for an AES cipher handle, AES-128 | ||
| 1344 | * is performed. | ||
| 1345 | * | ||
| 1346 | * Return: 0 if the setting of the key was successful; < 0 if an error occurred | ||
| 1347 | */ | ||
| 1348 | static inline int crypto_aead_setkey(struct crypto_aead *tfm, const u8 *key, | ||
| 1349 | unsigned int keylen) | ||
| 1350 | { | ||
| 1351 | struct aead_tfm *crt = crypto_aead_crt(tfm); | ||
| 1352 | |||
| 1353 | return crt->setkey(crt->base, key, keylen); | ||
| 1354 | } | ||
| 1355 | |||
| 1356 | /** | ||
| 1357 | * crypto_aead_setauthsize() - set authentication data size | ||
| 1358 | * @tfm: cipher handle | ||
| 1359 | * @authsize: size of the authentication data / tag in bytes | ||
| 1360 | * | ||
| 1361 | * Set the authentication data size / tag size. AEAD requires an authentication | ||
| 1362 | * tag (or MAC) in addition to the associated data. | ||
| 1363 | * | ||
| 1364 | * Return: 0 if the setting of the key was successful; < 0 if an error occurred | ||
| 1365 | */ | ||
| 1366 | int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize); | ||
| 1367 | |||
| 1368 | static inline struct crypto_aead *crypto_aead_reqtfm(struct aead_request *req) | ||
| 1369 | { | ||
| 1370 | return __crypto_aead_cast(req->base.tfm); | ||
| 1371 | } | ||
| 1372 | |||
| 1373 | /** | ||
| 1374 | * crypto_aead_encrypt() - encrypt plaintext | ||
| 1375 | * @req: reference to the aead_request handle that holds all information | ||
| 1376 | * needed to perform the cipher operation | ||
| 1377 | * | ||
| 1378 | * Encrypt plaintext data using the aead_request handle. That data structure | ||
| 1379 | * and how it is filled with data is discussed with the aead_request_* | ||
| 1380 | * functions. | ||
| 1381 | * | ||
| 1382 | * IMPORTANT NOTE The encryption operation creates the authentication data / | ||
| 1383 | * tag. That data is concatenated with the created ciphertext. | ||
| 1384 | * The ciphertext memory size is therefore the given number of | ||
| 1385 | * block cipher blocks + the size defined by the | ||
| 1386 | * crypto_aead_setauthsize invocation. The caller must ensure | ||
| 1387 | * that sufficient memory is available for the ciphertext and | ||
| 1388 | * the authentication tag. | ||
| 1389 | * | ||
| 1390 | * Return: 0 if the cipher operation was successful; < 0 if an error occurred | ||
| 1391 | */ | ||
| 1392 | static inline int crypto_aead_encrypt(struct aead_request *req) | ||
| 1393 | { | ||
| 1394 | return crypto_aead_crt(crypto_aead_reqtfm(req))->encrypt(req); | ||
| 1395 | } | ||
| 1396 | |||
| 1397 | /** | ||
| 1398 | * crypto_aead_decrypt() - decrypt ciphertext | ||
| 1399 | * @req: reference to the ablkcipher_request handle that holds all information | ||
| 1400 | * needed to perform the cipher operation | ||
| 1401 | * | ||
| 1402 | * Decrypt ciphertext data using the aead_request handle. That data structure | ||
| 1403 | * and how it is filled with data is discussed with the aead_request_* | ||
| 1404 | * functions. | ||
| 1405 | * | ||
| 1406 | * IMPORTANT NOTE The caller must concatenate the ciphertext followed by the | ||
| 1407 | * authentication data / tag. That authentication data / tag | ||
| 1408 | * must have the size defined by the crypto_aead_setauthsize | ||
| 1409 | * invocation. | ||
| 1410 | * | ||
| 1411 | * | ||
| 1412 | * Return: 0 if the cipher operation was successful; -EBADMSG: The AEAD | ||
| 1413 | * cipher operation performs the authentication of the data during the | ||
| 1414 | * decryption operation. Therefore, the function returns this error if | ||
| 1415 | * the authentication of the ciphertext was unsuccessful (i.e. the | ||
| 1416 | * integrity of the ciphertext or the associated data was violated); | ||
| 1417 | * < 0 if an error occurred. | ||
| 1418 | */ | ||
| 1419 | static inline int crypto_aead_decrypt(struct aead_request *req) | ||
| 1420 | { | ||
| 1421 | if (req->cryptlen < crypto_aead_authsize(crypto_aead_reqtfm(req))) | ||
| 1422 | return -EINVAL; | ||
| 1423 | |||
| 1424 | return crypto_aead_crt(crypto_aead_reqtfm(req))->decrypt(req); | ||
| 1425 | } | ||
| 1426 | |||
| 1427 | /** | ||
| 1428 | * DOC: Asynchronous AEAD Request Handle | ||
| 1429 | * | ||
| 1430 | * The aead_request data structure contains all pointers to data required for | ||
| 1431 | * the AEAD cipher operation. This includes the cipher handle (which can be | ||
| 1432 | * used by multiple aead_request instances), pointer to plaintext and | ||
| 1433 | * ciphertext, asynchronous callback function, etc. It acts as a handle to the | ||
| 1434 | * aead_request_* API calls in a similar way as AEAD handle to the | ||
| 1435 | * crypto_aead_* API calls. | ||
| 1436 | */ | ||
| 1437 | |||
| 1438 | /** | ||
| 1439 | * crypto_aead_reqsize() - obtain size of the request data structure | ||
| 1440 | * @tfm: cipher handle | ||
| 1441 | * | ||
| 1442 | * Return: number of bytes | ||
| 1443 | */ | ||
| 1444 | static inline unsigned int crypto_aead_reqsize(struct crypto_aead *tfm) | ||
| 1445 | { | ||
| 1446 | return crypto_aead_crt(tfm)->reqsize; | ||
| 1447 | } | ||
| 1448 | |||
| 1449 | /** | ||
| 1450 | * aead_request_set_tfm() - update cipher handle reference in request | ||
| 1451 | * @req: request handle to be modified | ||
| 1452 | * @tfm: cipher handle that shall be added to the request handle | ||
| 1453 | * | ||
| 1454 | * Allow the caller to replace the existing aead handle in the request | ||
| 1455 | * data structure with a different one. | ||
| 1456 | */ | ||
| 1457 | static inline void aead_request_set_tfm(struct aead_request *req, | ||
| 1458 | struct crypto_aead *tfm) | ||
| 1459 | { | ||
| 1460 | req->base.tfm = crypto_aead_tfm(crypto_aead_crt(tfm)->base); | ||
| 1461 | } | ||
| 1462 | |||
| 1463 | /** | ||
| 1464 | * aead_request_alloc() - allocate request data structure | ||
| 1465 | * @tfm: cipher handle to be registered with the request | ||
| 1466 | * @gfp: memory allocation flag that is handed to kmalloc by the API call. | ||
| 1467 | * | ||
| 1468 | * Allocate the request data structure that must be used with the AEAD | ||
| 1469 | * encrypt and decrypt API calls. During the allocation, the provided aead | ||
| 1470 | * handle is registered in the request data structure. | ||
| 1471 | * | ||
| 1472 | * Return: allocated request handle in case of success; IS_ERR() is true in case | ||
| 1473 | * of an error, PTR_ERR() returns the error code. | ||
| 1474 | */ | ||
| 1475 | static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm, | ||
| 1476 | gfp_t gfp) | ||
| 1477 | { | ||
| 1478 | struct aead_request *req; | ||
| 1479 | |||
| 1480 | req = kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp); | ||
| 1481 | |||
| 1482 | if (likely(req)) | ||
| 1483 | aead_request_set_tfm(req, tfm); | ||
| 1484 | |||
| 1485 | return req; | ||
| 1486 | } | ||
| 1487 | |||
| 1488 | /** | ||
| 1489 | * aead_request_free() - zeroize and free request data structure | ||
| 1490 | * @req: request data structure cipher handle to be freed | ||
| 1491 | */ | ||
| 1492 | static inline void aead_request_free(struct aead_request *req) | ||
| 1493 | { | ||
| 1494 | kzfree(req); | ||
| 1495 | } | ||
| 1496 | |||
| 1497 | /** | ||
| 1498 | * aead_request_set_callback() - set asynchronous callback function | ||
| 1499 | * @req: request handle | ||
| 1500 | * @flags: specify zero or an ORing of the flags | ||
| 1501 | * CRYPTO_TFM_REQ_MAY_BACKLOG the request queue may back log and | ||
| 1502 | * increase the wait queue beyond the initial maximum size; | ||
| 1503 | * CRYPTO_TFM_REQ_MAY_SLEEP the request processing may sleep | ||
| 1504 | * @compl: callback function pointer to be registered with the request handle | ||
| 1505 | * @data: The data pointer refers to memory that is not used by the kernel | ||
| 1506 | * crypto API, but provided to the callback function for it to use. Here, | ||
| 1507 | * the caller can provide a reference to memory the callback function can | ||
| 1508 | * operate on. As the callback function is invoked asynchronously to the | ||
| 1509 | * related functionality, it may need to access data structures of the | ||
| 1510 | * related functionality which can be referenced using this pointer. The | ||
| 1511 | * callback function can access the memory via the "data" field in the | ||
| 1512 | * crypto_async_request data structure provided to the callback function. | ||
| 1513 | * | ||
| 1514 | * Setting the callback function that is triggered once the cipher operation | ||
| 1515 | * completes | ||
| 1516 | * | ||
| 1517 | * The callback function is registered with the aead_request handle and | ||
| 1518 | * must comply with the following template | ||
| 1519 | * | ||
| 1520 | * void callback_function(struct crypto_async_request *req, int error) | ||
| 1521 | */ | ||
| 1522 | static inline void aead_request_set_callback(struct aead_request *req, | ||
| 1523 | u32 flags, | ||
| 1524 | crypto_completion_t compl, | ||
| 1525 | void *data) | ||
| 1526 | { | ||
| 1527 | req->base.complete = compl; | ||
| 1528 | req->base.data = data; | ||
| 1529 | req->base.flags = flags; | ||
| 1530 | } | ||
| 1531 | |||
| 1532 | /** | ||
| 1533 | * aead_request_set_crypt - set data buffers | ||
| 1534 | * @req: request handle | ||
| 1535 | * @src: source scatter / gather list | ||
| 1536 | * @dst: destination scatter / gather list | ||
| 1537 | * @cryptlen: number of bytes to process from @src | ||
| 1538 | * @iv: IV for the cipher operation which must comply with the IV size defined | ||
| 1539 | * by crypto_aead_ivsize() | ||
| 1540 | * | ||
| 1541 | * Setting the source data and destination data scatter / gather lists. | ||
| 1542 | * | ||
| 1543 | * For encryption, the source is treated as the plaintext and the | ||
| 1544 | * destination is the ciphertext. For a decryption operation, the use is | ||
| 1545 | * reversed - the source is the ciphertext and the destination is the plaintext. | ||
| 1546 | * | ||
| 1547 | * IMPORTANT NOTE AEAD requires an authentication tag (MAC). For decryption, | ||
| 1548 | * the caller must concatenate the ciphertext followed by the | ||
| 1549 | * authentication tag and provide the entire data stream to the | ||
| 1550 | * decryption operation (i.e. the data length used for the | ||
| 1551 | * initialization of the scatterlist and the data length for the | ||
| 1552 | * decryption operation is identical). For encryption, however, | ||
| 1553 | * the authentication tag is created while encrypting the data. | ||
| 1554 | * The destination buffer must hold sufficient space for the | ||
| 1555 | * ciphertext and the authentication tag while the encryption | ||
| 1556 | * invocation must only point to the plaintext data size. The | ||
| 1557 | * following code snippet illustrates the memory usage | ||
| 1558 | * buffer = kmalloc(ptbuflen + (enc ? authsize : 0)); | ||
| 1559 | * sg_init_one(&sg, buffer, ptbuflen + (enc ? authsize : 0)); | ||
| 1560 | * aead_request_set_crypt(req, &sg, &sg, ptbuflen, iv); | ||
| 1561 | */ | ||
| 1562 | static inline void aead_request_set_crypt(struct aead_request *req, | ||
| 1563 | struct scatterlist *src, | ||
| 1564 | struct scatterlist *dst, | ||
| 1565 | unsigned int cryptlen, u8 *iv) | ||
| 1566 | { | ||
| 1567 | req->src = src; | ||
| 1568 | req->dst = dst; | ||
| 1569 | req->cryptlen = cryptlen; | ||
| 1570 | req->iv = iv; | ||
| 1571 | } | ||
| 1572 | |||
| 1573 | /** | ||
| 1574 | * aead_request_set_assoc() - set the associated data scatter / gather list | ||
| 1575 | * @req: request handle | ||
| 1576 | * @assoc: associated data scatter / gather list | ||
| 1577 | * @assoclen: number of bytes to process from @assoc | ||
| 1578 | * | ||
| 1579 | * For encryption, the memory is filled with the associated data. For | ||
| 1580 | * decryption, the memory must point to the associated data. | ||
| 1581 | */ | ||
| 1582 | static inline void aead_request_set_assoc(struct aead_request *req, | ||
| 1583 | struct scatterlist *assoc, | ||
| 1584 | unsigned int assoclen) | ||
| 1585 | { | ||
| 1586 | req->assoc = assoc; | ||
| 1587 | req->assoclen = assoclen; | ||
| 1588 | } | ||
| 1589 | |||
| 1590 | /** | ||
| 1591 | * DOC: Synchronous Block Cipher API | 1116 | * DOC: Synchronous Block Cipher API |
| 1592 | * | 1117 | * |
| 1593 | * The synchronous block cipher API is used with the ciphers of type | 1118 | * The synchronous block cipher API is used with the ciphers of type |
diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h deleted file mode 100644 index 4abf2ea6a887..000000000000 --- a/include/linux/cryptouser.h +++ /dev/null | |||
| @@ -1,105 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Crypto user configuration API. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2011 secunet Security Networks AG | ||
| 5 | * Copyright (C) 2011 Steffen Klassert <steffen.klassert@secunet.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify it | ||
| 8 | * under the terms and conditions of the GNU General Public License, | ||
| 9 | * version 2, as published by the Free Software Foundation. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 14 | * more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License along with | ||
| 17 | * this program; if not, write to the Free Software Foundation, Inc., | ||
| 18 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /* Netlink configuration messages. */ | ||
| 22 | enum { | ||
| 23 | CRYPTO_MSG_BASE = 0x10, | ||
| 24 | CRYPTO_MSG_NEWALG = 0x10, | ||
| 25 | CRYPTO_MSG_DELALG, | ||
| 26 | CRYPTO_MSG_UPDATEALG, | ||
| 27 | CRYPTO_MSG_GETALG, | ||
| 28 | __CRYPTO_MSG_MAX | ||
| 29 | }; | ||
| 30 | #define CRYPTO_MSG_MAX (__CRYPTO_MSG_MAX - 1) | ||
| 31 | #define CRYPTO_NR_MSGTYPES (CRYPTO_MSG_MAX + 1 - CRYPTO_MSG_BASE) | ||
| 32 | |||
| 33 | #define CRYPTO_MAX_NAME CRYPTO_MAX_ALG_NAME | ||
| 34 | |||
| 35 | /* Netlink message attributes. */ | ||
| 36 | enum crypto_attr_type_t { | ||
| 37 | CRYPTOCFGA_UNSPEC, | ||
| 38 | CRYPTOCFGA_PRIORITY_VAL, /* __u32 */ | ||
| 39 | CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */ | ||
| 40 | CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */ | ||
| 41 | CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */ | ||
| 42 | CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */ | ||
| 43 | CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */ | ||
| 44 | CRYPTOCFGA_REPORT_RNG, /* struct crypto_report_rng */ | ||
| 45 | CRYPTOCFGA_REPORT_CIPHER, /* struct crypto_report_cipher */ | ||
| 46 | __CRYPTOCFGA_MAX | ||
| 47 | |||
| 48 | #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) | ||
| 49 | }; | ||
| 50 | |||
| 51 | struct crypto_user_alg { | ||
| 52 | char cru_name[CRYPTO_MAX_ALG_NAME]; | ||
| 53 | char cru_driver_name[CRYPTO_MAX_ALG_NAME]; | ||
| 54 | char cru_module_name[CRYPTO_MAX_ALG_NAME]; | ||
| 55 | __u32 cru_type; | ||
| 56 | __u32 cru_mask; | ||
| 57 | __u32 cru_refcnt; | ||
| 58 | __u32 cru_flags; | ||
| 59 | }; | ||
| 60 | |||
| 61 | struct crypto_report_larval { | ||
| 62 | char type[CRYPTO_MAX_NAME]; | ||
| 63 | }; | ||
| 64 | |||
| 65 | struct crypto_report_hash { | ||
| 66 | char type[CRYPTO_MAX_NAME]; | ||
| 67 | unsigned int blocksize; | ||
| 68 | unsigned int digestsize; | ||
| 69 | }; | ||
| 70 | |||
| 71 | struct crypto_report_cipher { | ||
| 72 | char type[CRYPTO_MAX_ALG_NAME]; | ||
| 73 | unsigned int blocksize; | ||
| 74 | unsigned int min_keysize; | ||
| 75 | unsigned int max_keysize; | ||
| 76 | }; | ||
| 77 | |||
| 78 | struct crypto_report_blkcipher { | ||
| 79 | char type[CRYPTO_MAX_NAME]; | ||
| 80 | char geniv[CRYPTO_MAX_NAME]; | ||
| 81 | unsigned int blocksize; | ||
| 82 | unsigned int min_keysize; | ||
| 83 | unsigned int max_keysize; | ||
| 84 | unsigned int ivsize; | ||
| 85 | }; | ||
| 86 | |||
| 87 | struct crypto_report_aead { | ||
| 88 | char type[CRYPTO_MAX_NAME]; | ||
| 89 | char geniv[CRYPTO_MAX_NAME]; | ||
| 90 | unsigned int blocksize; | ||
| 91 | unsigned int maxauthsize; | ||
| 92 | unsigned int ivsize; | ||
| 93 | }; | ||
| 94 | |||
| 95 | struct crypto_report_comp { | ||
| 96 | char type[CRYPTO_MAX_NAME]; | ||
| 97 | }; | ||
| 98 | |||
| 99 | struct crypto_report_rng { | ||
| 100 | char type[CRYPTO_MAX_NAME]; | ||
| 101 | unsigned int seedsize; | ||
| 102 | }; | ||
| 103 | |||
| 104 | #define CRYPTO_REPORT_MAXSIZE (sizeof(struct crypto_user_alg) + \ | ||
| 105 | sizeof(struct crypto_report_blkcipher)) | ||
diff --git a/include/linux/mbus.h b/include/linux/mbus.h index 611b69fa8594..1f7bc630d225 100644 --- a/include/linux/mbus.h +++ b/include/linux/mbus.h | |||
| @@ -54,11 +54,16 @@ struct mbus_dram_target_info | |||
| 54 | */ | 54 | */ |
| 55 | #ifdef CONFIG_PLAT_ORION | 55 | #ifdef CONFIG_PLAT_ORION |
| 56 | extern const struct mbus_dram_target_info *mv_mbus_dram_info(void); | 56 | extern const struct mbus_dram_target_info *mv_mbus_dram_info(void); |
| 57 | extern const struct mbus_dram_target_info *mv_mbus_dram_info_nooverlap(void); | ||
| 57 | #else | 58 | #else |
| 58 | static inline const struct mbus_dram_target_info *mv_mbus_dram_info(void) | 59 | static inline const struct mbus_dram_target_info *mv_mbus_dram_info(void) |
| 59 | { | 60 | { |
| 60 | return NULL; | 61 | return NULL; |
| 61 | } | 62 | } |
| 63 | static inline const struct mbus_dram_target_info *mv_mbus_dram_info_nooverlap(void) | ||
| 64 | { | ||
| 65 | return NULL; | ||
| 66 | } | ||
| 62 | #endif | 67 | #endif |
| 63 | 68 | ||
| 64 | int mvebu_mbus_save_cpu_target(u32 *store_addr); | 69 | int mvebu_mbus_save_cpu_target(u32 *store_addr); |
diff --git a/include/linux/module.h b/include/linux/module.h index c883b86ea964..1e5436042eb0 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
| @@ -655,4 +655,16 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr, | |||
| 655 | static inline void module_bug_cleanup(struct module *mod) {} | 655 | static inline void module_bug_cleanup(struct module *mod) {} |
| 656 | #endif /* CONFIG_GENERIC_BUG */ | 656 | #endif /* CONFIG_GENERIC_BUG */ |
| 657 | 657 | ||
| 658 | #ifdef CONFIG_MODULE_SIG | ||
| 659 | static inline bool module_sig_ok(struct module *module) | ||
| 660 | { | ||
| 661 | return module->sig_ok; | ||
| 662 | } | ||
| 663 | #else /* !CONFIG_MODULE_SIG */ | ||
| 664 | static inline bool module_sig_ok(struct module *module) | ||
| 665 | { | ||
| 666 | return true; | ||
| 667 | } | ||
| 668 | #endif /* CONFIG_MODULE_SIG */ | ||
| 669 | |||
| 658 | #endif /* _LINUX_MODULE_H */ | 670 | #endif /* _LINUX_MODULE_H */ |
diff --git a/include/linux/mpi.h b/include/linux/mpi.h index 5af1b81def49..641b7d6fd096 100644 --- a/include/linux/mpi.h +++ b/include/linux/mpi.h | |||
| @@ -81,6 +81,8 @@ MPI mpi_read_from_buffer(const void *buffer, unsigned *ret_nread); | |||
| 81 | int mpi_fromstr(MPI val, const char *str); | 81 | int mpi_fromstr(MPI val, const char *str); |
| 82 | u32 mpi_get_keyid(MPI a, u32 *keyid); | 82 | u32 mpi_get_keyid(MPI a, u32 *keyid); |
| 83 | void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign); | 83 | void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign); |
| 84 | int mpi_read_buffer(MPI a, uint8_t *buf, unsigned buf_len, unsigned *nbytes, | ||
| 85 | int *sign); | ||
| 84 | void *mpi_get_secure_buffer(MPI a, unsigned *nbytes, int *sign); | 86 | void *mpi_get_secure_buffer(MPI a, unsigned *nbytes, int *sign); |
| 85 | int mpi_set_buffer(MPI a, const void *buffer, unsigned nbytes, int sign); | 87 | int mpi_set_buffer(MPI a, const void *buffer, unsigned nbytes, int sign); |
| 86 | 88 | ||
| @@ -142,4 +144,17 @@ int mpi_rshift(MPI x, MPI a, unsigned n); | |||
| 142 | /*-- mpi-inv.c --*/ | 144 | /*-- mpi-inv.c --*/ |
| 143 | int mpi_invm(MPI x, MPI u, MPI v); | 145 | int mpi_invm(MPI x, MPI u, MPI v); |
| 144 | 146 | ||
| 147 | /* inline functions */ | ||
| 148 | |||
| 149 | /** | ||
| 150 | * mpi_get_size() - returns max size required to store the number | ||
| 151 | * | ||
| 152 | * @a: A multi precision integer for which we want to allocate a bufer | ||
| 153 | * | ||
| 154 | * Return: size required to store the number | ||
| 155 | */ | ||
| 156 | static inline unsigned int mpi_get_size(MPI a) | ||
| 157 | { | ||
| 158 | return a->nlimbs * BYTES_PER_MPI_LIMB; | ||
| 159 | } | ||
| 145 | #endif /*G10_MPI_H */ | 160 | #endif /*G10_MPI_H */ |
diff --git a/include/linux/nx842.h b/include/linux/nx842.h deleted file mode 100644 index a4d324c6406a..000000000000 --- a/include/linux/nx842.h +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | #ifndef __NX842_H__ | ||
| 2 | #define __NX842_H__ | ||
| 3 | |||
| 4 | int nx842_get_workmem_size(void); | ||
| 5 | int nx842_get_workmem_size_aligned(void); | ||
| 6 | int nx842_compress(const unsigned char *in, unsigned int in_len, | ||
| 7 | unsigned char *out, unsigned int *out_len, void *wrkmem); | ||
| 8 | int nx842_decompress(const unsigned char *in, unsigned int in_len, | ||
| 9 | unsigned char *out, unsigned int *out_len, void *wrkmem); | ||
| 10 | |||
| 11 | #endif | ||
diff --git a/include/linux/random.h b/include/linux/random.h index b05856e16b75..e651874df2c9 100644 --- a/include/linux/random.h +++ b/include/linux/random.h | |||
| @@ -6,14 +6,23 @@ | |||
| 6 | #ifndef _LINUX_RANDOM_H | 6 | #ifndef _LINUX_RANDOM_H |
| 7 | #define _LINUX_RANDOM_H | 7 | #define _LINUX_RANDOM_H |
| 8 | 8 | ||
| 9 | #include <linux/list.h> | ||
| 9 | #include <uapi/linux/random.h> | 10 | #include <uapi/linux/random.h> |
| 10 | 11 | ||
| 12 | struct random_ready_callback { | ||
| 13 | struct list_head list; | ||
| 14 | void (*func)(struct random_ready_callback *rdy); | ||
| 15 | struct module *owner; | ||
| 16 | }; | ||
| 17 | |||
| 11 | extern void add_device_randomness(const void *, unsigned int); | 18 | extern void add_device_randomness(const void *, unsigned int); |
| 12 | extern void add_input_randomness(unsigned int type, unsigned int code, | 19 | extern void add_input_randomness(unsigned int type, unsigned int code, |
| 13 | unsigned int value); | 20 | unsigned int value); |
| 14 | extern void add_interrupt_randomness(int irq, int irq_flags); | 21 | extern void add_interrupt_randomness(int irq, int irq_flags); |
| 15 | 22 | ||
| 16 | extern void get_random_bytes(void *buf, int nbytes); | 23 | extern void get_random_bytes(void *buf, int nbytes); |
| 24 | extern int add_random_ready_callback(struct random_ready_callback *rdy); | ||
| 25 | extern void del_random_ready_callback(struct random_ready_callback *rdy); | ||
| 17 | extern void get_random_bytes_arch(void *buf, int nbytes); | 26 | extern void get_random_bytes_arch(void *buf, int nbytes); |
| 18 | void generate_random_uuid(unsigned char uuid_out[16]); | 27 | void generate_random_uuid(unsigned char uuid_out[16]); |
| 19 | extern int random_int_secret_init(void); | 28 | extern int random_int_secret_init(void); |
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index ed8f9e70df9b..a0edb992c9c3 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h | |||
| @@ -221,6 +221,7 @@ static inline void *sg_virt(struct scatterlist *sg) | |||
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | int sg_nents(struct scatterlist *sg); | 223 | int sg_nents(struct scatterlist *sg); |
| 224 | int sg_nents_for_len(struct scatterlist *sg, u64 len); | ||
| 224 | struct scatterlist *sg_next(struct scatterlist *); | 225 | struct scatterlist *sg_next(struct scatterlist *); |
| 225 | struct scatterlist *sg_last(struct scatterlist *s, unsigned int); | 226 | struct scatterlist *sg_last(struct scatterlist *s, unsigned int); |
| 226 | void sg_init_table(struct scatterlist *, unsigned int); | 227 | void sg_init_table(struct scatterlist *, unsigned int); |
diff --git a/include/linux/sw842.h b/include/linux/sw842.h new file mode 100644 index 000000000000..109ba041c2ae --- /dev/null +++ b/include/linux/sw842.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | #ifndef __SW842_H__ | ||
| 2 | #define __SW842_H__ | ||
| 3 | |||
| 4 | #define SW842_MEM_COMPRESS (0xf000) | ||
| 5 | |||
| 6 | int sw842_compress(const u8 *src, unsigned int srclen, | ||
| 7 | u8 *dst, unsigned int *destlen, void *wmem); | ||
| 8 | |||
| 9 | int sw842_decompress(const u8 *src, unsigned int srclen, | ||
| 10 | u8 *dst, unsigned int *destlen); | ||
| 11 | |||
| 12 | #endif | ||
