Lines Matching +full:key +full:- +full:code

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Public Key Encryption
15 * struct akcipher_request - public key request
45 * struct crypto_akcipher - user-instantiated objects which encapsulate
58 * struct crypto_istat_akcipher - statistics for akcipher algorithm
78 * struct akcipher_alg - generic public key algorithm
80 * @sign: Function performs a sign operation as defined by public key
82 * the req->dst_len will be updated to the size required for the
85 * public key algorithm, returning verification status. Requires
87 * @encrypt: Function performs an encrypt operation as defined by public key
89 * the req->dst_len will be updated to the size required for the
91 * @decrypt: Function performs a decrypt operation as defined by public key
93 * the req->dst_len will be updated to the size required for the
95 * @set_pub_key: Function invokes the algorithm specific set public key
97 * the BER encoded public key and parameters
98 * @set_priv_key: Function invokes the algorithm specific set private key
100 * the BER encoded private key and parameters
101 * @max_size: Function returns dest buffer size required for a given key.
122 int (*set_pub_key)(struct crypto_akcipher *tfm, const void *key,
124 int (*set_priv_key)(struct crypto_akcipher *tfm, const void *key,
138 * DOC: Generic Public Key API
140 * The Public Key API is used with the algorithms of type
145 * crypto_alloc_akcipher() - allocate AKCIPHER tfm handle
147 * public key algorithm e.g. "rsa"
151 * Allocate a handle for public key algorithm. The returned struct
153 * API invocation for the public key operations.
156 * of an error, PTR_ERR() returns the error code.
164 return &tfm->base; in crypto_akcipher_tfm()
181 return __crypto_akcipher_alg(crypto_akcipher_tfm(tfm)->__crt_alg); in crypto_akcipher_alg()
186 return tfm->reqsize; in crypto_akcipher_reqsize()
192 req->base.tfm = crypto_akcipher_tfm(tfm); in akcipher_request_set_tfm()
198 return __crypto_akcipher_tfm(req->base.tfm); in crypto_akcipher_reqtfm()
202 * crypto_free_akcipher() - free AKCIPHER tfm handle
214 * akcipher_request_alloc() - allocates public key request
234 * akcipher_request_free() - zeroize and free public key request
244 * akcipher_request_set_callback() - Sets an asynchronous callback.
259 req->base.complete = cmpl; in akcipher_request_set_callback()
260 req->base.data = data; in akcipher_request_set_callback()
261 req->base.flags = flgs; in akcipher_request_set_callback()
265 * akcipher_request_set_crypt() - Sets request parameters
269 * @req: public key request
282 req->src = src; in akcipher_request_set_crypt()
283 req->dst = dst; in akcipher_request_set_crypt()
284 req->src_len = src_len; in akcipher_request_set_crypt()
285 req->dst_len = dst_len; in akcipher_request_set_crypt()
289 * crypto_akcipher_maxsize() - Get len for output buffer
291 * Function returns the dest buffer size required for a given key.
292 * Function assumes that the key is already set in the transformation. If this
302 return alg->max_size(tfm); in crypto_akcipher_maxsize()
309 return &alg->stat; in akcipher_get_stat()
320 if (err && err != -EINPROGRESS && err != -EBUSY) in crypto_akcipher_errstat()
321 atomic64_inc(&akcipher_get_stat(alg)->err_cnt); in crypto_akcipher_errstat()
327 * crypto_akcipher_encrypt() - Invoke public key encrypt operation
329 * Function invokes the specific public key encrypt operation for a given
330 * public key algorithm
332 * @req: asymmetric key request
334 * Return: zero on success; error code in case of error
344 atomic64_inc(&istat->encrypt_cnt); in crypto_akcipher_encrypt()
345 atomic64_add(req->src_len, &istat->encrypt_tlen); in crypto_akcipher_encrypt()
348 return crypto_akcipher_errstat(alg, alg->encrypt(req)); in crypto_akcipher_encrypt()
352 * crypto_akcipher_decrypt() - Invoke public key decrypt operation
354 * Function invokes the specific public key decrypt operation for a given
355 * public key algorithm
357 * @req: asymmetric key request
359 * Return: zero on success; error code in case of error
369 atomic64_inc(&istat->decrypt_cnt); in crypto_akcipher_decrypt()
370 atomic64_add(req->src_len, &istat->decrypt_tlen); in crypto_akcipher_decrypt()
373 return crypto_akcipher_errstat(alg, alg->decrypt(req)); in crypto_akcipher_decrypt()
377 * crypto_akcipher_sync_encrypt() - Invoke public key encrypt operation
379 * Function invokes the specific public key encrypt operation for a given
380 * public key algorithm
388 * Return: zero on success; error code in case of error
395 * crypto_akcipher_sync_decrypt() - Invoke public key decrypt operation
397 * Function invokes the specific public key decrypt operation for a given
398 * public key algorithm
406 * Return: Output length on success; error code in case of error
413 * crypto_akcipher_sign() - Invoke public key sign operation
415 * Function invokes the specific public key sign operation for a given
416 * public key algorithm
418 * @req: asymmetric key request
420 * Return: zero on success; error code in case of error
428 atomic64_inc(&akcipher_get_stat(alg)->sign_cnt); in crypto_akcipher_sign()
430 return crypto_akcipher_errstat(alg, alg->sign(req)); in crypto_akcipher_sign()
434 * crypto_akcipher_verify() - Invoke public key signature verification
436 * Function invokes the specific public key signature verification operation
437 * for a given public key algorithm.
439 * @req: asymmetric key request
441 * Note: req->dst should be NULL, req->src should point to SG of size
442 * (req->src_size + req->dst_size), containing signature (of req->src_size
443 * length) with appended digest (of req->dst_size length).
445 * Return: zero on verification success; error code in case of error.
453 atomic64_inc(&akcipher_get_stat(alg)->verify_cnt); in crypto_akcipher_verify()
455 return crypto_akcipher_errstat(alg, alg->verify(req)); in crypto_akcipher_verify()
459 * crypto_akcipher_set_pub_key() - Invoke set public key operation
461 * Function invokes the algorithm specific set key function, which knows
462 * how to decode and interpret the encoded key and parameters
465 * @key: BER encoded public key, algo OID, paramlen, BER encoded
467 * @keylen: length of the key (not including other data)
469 * Return: zero on success; error code in case of error
472 const void *key, in crypto_akcipher_set_pub_key() argument
477 return alg->set_pub_key(tfm, key, keylen); in crypto_akcipher_set_pub_key()
481 * crypto_akcipher_set_priv_key() - Invoke set private key operation
483 * Function invokes the algorithm specific set key function, which knows
484 * how to decode and interpret the encoded key and parameters
487 * @key: BER encoded private key, algo OID, paramlen, BER encoded
489 * @keylen: length of the key (not including other data)
491 * Return: zero on success; error code in case of error
494 const void *key, in crypto_akcipher_set_priv_key() argument
499 return alg->set_priv_key(tfm, key, keylen); in crypto_akcipher_set_priv_key()