__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Public Key Signature Algorithm * * Copyright (c) 2023 Herbert Xu <[email protected]> */ #ifndef _CRYPTO_SIG_H #define _CRYPTO_SIG_H #include <linux/crypto.h> /** * struct crypto_sig - user-instantiated objects which encapsulate * algorithms and core processing logic * * @base: Common crypto API algorithm data structure */ struct crypto_sig { struct crypto_tfm base; }; /** * struct sig_alg - generic public key signature algorithm * * @sign: Function performs a sign operation as defined by public key * algorithm. Optional. * @verify: Function performs a complete verify operation as defined by * public key algorithm, returning verification status. Optional. * @set_pub_key: Function invokes the algorithm specific set public key * function, which knows how to decode and interpret * the BER encoded public key and parameters. Mandatory. * @set_priv_key: Function invokes the algorithm specific set private key * function, which knows how to decode and interpret * the BER encoded private key and parameters. Optional. * @key_size: Function returns key size. Mandatory. * @digest_size: Function returns maximum digest size. Optional. * @max_size: Function returns maximum signature size. Optional. * @init: Initialize the cryptographic transformation object. * This function is used to initialize the cryptographic * transformation object. This function is called only once at * the instantiation time, right after the transformation context * was allocated. In case the cryptographic hardware has some * special requirements which need to be handled by software, this * function shall check for the precise requirement of the * transformation and put any software fallbacks in place. * @exit: Deinitialize the cryptographic transformation object. This is a * counterpart to @init, used to remove various changes set in * @init. * * @base: Common crypto API algorithm data structure */ struct sig_alg { int (*sign)(struct crypto_sig *tfm, const void *src, unsigned int slen, void *dst, unsigned int dlen); int (*verify)(struct crypto_sig *tfm, const void *src, unsigned int slen, const void *digest, unsigned int dlen); int (*set_pub_key)(struct crypto_sig *tfm, const void *key, unsigned int keylen); int (*set_priv_key)(struct crypto_sig *tfm, const void *key, unsigned int keylen); unsigned int (*key_size)(struct crypto_sig *tfm); unsigned int (*digest_size)(struct crypto_sig *tfm); unsigned int (*max_size)(struct crypto_sig *tfm); int (*init)(struct crypto_sig *tfm); void (*exit)(struct crypto_sig *tfm); struct crypto_alg base; }; /** * DOC: Generic Public Key Signature API * * The Public Key Signature API is used with the algorithms of type * CRYPTO_ALG_TYPE_SIG (listed as type "sig" in /proc/crypto) */ /** * crypto_alloc_sig() - allocate signature tfm handle * @alg_name: is the cra_name / name or cra_driver_name / driver name of the * signing algorithm e.g. "ecdsa" * @type: specifies the type of the algorithm * @mask: specifies the mask for the algorithm * * Allocate a handle for public key signature algorithm. The returned struct * crypto_sig is the handle that is required for any subsequent * API invocation for signature operations. * * Return: allocated handle in case of success; IS_ERR() is true in case * of an error, PTR_ERR() returns the error code. */ struct crypto_sig *crypto_alloc_sig(const char *alg_name, u32 type, u32 mask); static inline struct crypto_tfm *crypto_sig_tfm(struct crypto_sig *tfm) { return &tfm->base; } static inline struct crypto_sig *__crypto_sig_tfm(struct crypto_tfm *tfm) { return container_of(tfm, struct crypto_sig, base); } static inline struct sig_alg *__crypto_sig_alg(struct crypto_alg *alg) { return container_of(alg, struct sig_alg, base); } static inline struct sig_alg *crypto_sig_alg(struct crypto_sig *tfm) { return __crypto_sig_alg(crypto_sig_tfm(tfm)->__crt_alg); } /** * crypto_free_sig() - free signature tfm handle * * @tfm: signature tfm handle allocated with crypto_alloc_sig() * * If @tfm is a NULL or error pointer, this function does nothing. */ static inline void crypto_free_sig(struct crypto_sig *tfm) { crypto_destroy_tfm(tfm, crypto_sig_tfm(tfm)); } /** * crypto_sig_keysize() - Get key size * * Function returns the key size in bits. * Function assumes that the key is already set in the transformation. If this * function is called without a setkey or with a failed setkey, you may end up * in a NULL dereference. * * @tfm: signature tfm handle allocated with crypto_alloc_sig() */ static inline unsigned int crypto_sig_keysize(struct crypto_sig *tfm) { struct sig_alg *alg = crypto_sig_alg(tfm); return alg->key_size(tfm); } /** * crypto_sig_digestsize() - Get maximum digest size * * Function returns the maximum digest size in bytes. * Function assumes that the key is already set in the transformation. If this * function is called without a setkey or with a failed setkey, you may end up * in a NULL dereference. * * @tfm: signature tfm handle allocated with crypto_alloc_sig() */ static inline unsigned int crypto_sig_digestsize(struct crypto_sig *tfm) { struct sig_alg *alg = crypto_sig_alg(tfm); return alg->digest_size(tfm); } /** * crypto_sig_maxsize() - Get maximum signature size * * Function returns the maximum signature size in bytes. * Function assumes that the key is already set in the transformation. If this * function is called without a setkey or with a failed setkey, you may end up * in a NULL dereference. * * @tfm: signature tfm handle allocated with crypto_alloc_sig() */ static inline unsigned int crypto_sig_maxsize(struct crypto_sig *tfm) { struct sig_alg *alg = crypto_sig_alg(tfm); return alg->max_size(tfm); } /** * crypto_sig_sign() - Invoke signing operation * * Function invokes the specific signing operation for a given algorithm * * @tfm: signature tfm handle allocated with crypto_alloc_sig() * @src: source buffer * @slen: source length * @dst: destination obuffer * @dlen: destination length * * Return: zero on success; error code in case of error */ static inline int crypto_sig_sign(struct crypto_sig *tfm, const void *src, unsigned int slen, void *dst, unsigned int dlen) { struct sig_alg *alg = crypto_sig_alg(tfm); return alg->sign(tfm, src, slen, dst, dlen); } /** * crypto_sig_verify() - Invoke signature verification * * Function invokes the specific signature verification operation * for a given algorithm. * * @tfm: signature tfm handle allocated with crypto_alloc_sig() * @src: source buffer * @slen: source length * @digest: digest * @dlen: digest length * * Return: zero on verification success; error code in case of error. */ static inline int crypto_sig_verify(struct crypto_sig *tfm, const void *src, unsigned int slen, const void *digest, unsigned int dlen) { struct sig_alg *alg = crypto_sig_alg(tfm); return alg->verify(tfm, src, slen, digest, dlen); } /** * crypto_sig_set_pubkey() - Invoke set public key operation * * Function invokes the algorithm specific set key function, which knows * how to decode and interpret the encoded key and parameters * * @tfm: tfm handle * @key: BER encoded public key, algo OID, paramlen, BER encoded * parameters * @keylen: length of the key (not including other data) * * Return: zero on success; error code in case of error */ static inline int crypto_sig_set_pubkey(struct crypto_sig *tfm, const void *key, unsigned int keylen) { struct sig_alg *alg = crypto_sig_alg(tfm); return alg->set_pub_key(tfm, key, keylen); } /** * crypto_sig_set_privkey() - Invoke set private key operation * * Function invokes the algorithm specific set key function, which knows * how to decode and interpret the encoded key and parameters * * @tfm: tfm handle * @key: BER encoded private key, algo OID, paramlen, BER encoded * parameters * @keylen: length of the key (not including other data) * * Return: zero on success; error code in case of error */ static inline int crypto_sig_set_privkey(struct crypto_sig *tfm, const void *key, unsigned int keylen) { struct sig_alg *alg = crypto_sig_alg(tfm); return alg->set_priv_key(tfm, key, keylen); } #endif
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| internal | Folder | 0755 |
|
|
| acompress.h | File | 7.7 KB | 0644 |
|
| aead.h | File | 18.89 KB | 0644 |
|
| aes.h | File | 2.74 KB | 0644 |
|
| akcipher.h | File | 11.32 KB | 0644 |
|
| algapi.h | File | 7.55 KB | 0644 |
|
| arc4.h | File | 484 B | 0644 |
|
| aria.h | File | 16.71 KB | 0644 |
|
| authenc.h | File | 635 B | 0644 |
|
| b128ops.h | File | 2.26 KB | 0644 |
|
| blake2b.h | File | 1.57 KB | 0644 |
|
| blake2s.h | File | 2.62 KB | 0644 |
|
| blowfish.h | File | 415 B | 0644 |
|
| cast5.h | File | 590 B | 0644 |
|
| cast6.h | File | 607 B | 0644 |
|
| cast_common.h | File | 232 B | 0644 |
|
| chacha.h | File | 3.32 KB | 0644 |
|
| chacha20poly1305.h | File | 1.66 KB | 0644 |
|
| cryptd.h | File | 2 KB | 0644 |
|
| ctr.h | File | 1.42 KB | 0644 |
|
| curve25519.h | File | 2.02 KB | 0644 |
|
| des.h | File | 1.68 KB | 0644 |
|
| dh.h | File | 3.03 KB | 0644 |
|
| drbg.h | File | 9.02 KB | 0644 |
|
| ecc_curve.h | File | 1.36 KB | 0644 |
|
| ecdh.h | File | 2.46 KB | 0644 |
|
| engine.h | File | 3.72 KB | 0644 |
|
| gcm.h | File | 1.48 KB | 0644 |
|
| gf128mul.h | File | 9.25 KB | 0644 |
|
| ghash.h | File | 388 B | 0644 |
|
| hash.h | File | 33.06 KB | 0644 |
|
| hash_info.h | File | 1023 B | 0644 |
|
| hmac.h | File | 173 B | 0644 |
|
| if_alg.h | File | 6.57 KB | 0644 |
|
| kdf_sp800108.h | File | 2.07 KB | 0644 |
|
| kpp.h | File | 9.53 KB | 0644 |
|
| md5.h | File | 497 B | 0644 |
|
| nhpoly1305.h | File | 2.18 KB | 0644 |
|
| null.h | File | 346 B | 0644 |
|
| padlock.h | File | 438 B | 0644 |
|
| pcrypt.h | File | 821 B | 0644 |
|
| pkcs7.h | File | 1.15 KB | 0644 |
|
| poly1305.h | File | 2.44 KB | 0644 |
|
| polyval.h | File | 445 B | 0644 |
|
| public_key.h | File | 3.39 KB | 0644 |
|
| rng.h | File | 6.61 KB | 0644 |
|
| scatterwalk.h | File | 2.74 KB | 0644 |
|
| serpent.h | File | 696 B | 0644 |
|
| sha1.h | File | 1.18 KB | 0644 |
|
| sha1_base.h | File | 2.46 KB | 0644 |
|
| sha2.h | File | 3.75 KB | 0644 |
|
| sha256_base.h | File | 3.12 KB | 0644 |
|
| sha3.h | File | 879 B | 0644 |
|
| sha512_base.h | File | 3.18 KB | 0644 |
|
| sig.h | File | 8.2 KB | 0644 |
|
| skcipher.h | File | 32.47 KB | 0644 |
|
| sm3.h | File | 1.6 KB | 0644 |
|
| sm3_base.h | File | 2.55 KB | 0644 |
|
| sm4.h | File | 1.22 KB | 0644 |
|
| streebog.h | File | 949 B | 0644 |
|
| twofish.h | File | 743 B | 0644 |
|
| utils.h | File | 1.89 KB | 0644 |
|
| xts.h | File | 978 B | 0644 |
|