Lines Matching +full:key +full:- +full:code
1 Code Examples
4 Code Example For Symmetric Key Cipher Operation
5 -----------------------------------------------
7 This code encrypts some data with AES-256-XTS. For sake of example,
8 all inputs are random bytes, the encryption is done in-place, and it's
9 assumed the code is running in a context where it can sleep.
21 u8 iv[16]; /* AES-256-XTS takes a 16-byte IV */
22 u8 key[64]; /* AES-256-XTS takes a 64-byte key */
26 * Allocate a tfm (a transformation object) and set the key.
28 * In real-world use, a tfm and key are typically used for many
39 get_random_bytes(key, sizeof(key));
40 err = crypto_skcipher_setkey(tfm, key, sizeof(key));
42 pr_err("Error setting key: %d\n", err);
49 err = -ENOMEM;
56 err = -ENOMEM;
65 * Encrypt the data in-place.
93 Code Example For Use of Operational State Memory With SHASH
94 -----------------------------------------------------------
112 return ERR_PTR(-ENOMEM);
113 sdesc->shash.tfm = alg;
130 ret = crypto_shash_digest(&sdesc->shash, data, datalen, digest);
139 char *hash_alg_name = "sha1-padlock-nano";
153 Code Example For Random Number Generator Usage
154 ----------------------------------------------
162 char *drbg = "drbg_nopr_sha256"; /* Hash DRBG with SHA-256, no PR */
167 return -EINVAL;