Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /* Asymmetric public-key algorithm definitions
0003  *
0004  * See Documentation/crypto/asymmetric-keys.rst
0005  *
0006  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
0007  * Written by David Howells (dhowells@redhat.com)
0008  */
0009 
0010 #ifndef _LINUX_PUBLIC_KEY_H
0011 #define _LINUX_PUBLIC_KEY_H
0012 
0013 #include <linux/keyctl.h>
0014 #include <linux/oid_registry.h>
0015 
0016 /*
0017  * Cryptographic data for the public-key subtype of the asymmetric key type.
0018  *
0019  * Note that this may include private part of the key as well as the public
0020  * part.
0021  */
0022 struct public_key {
0023     void *key;
0024     u32 keylen;
0025     enum OID algo;
0026     void *params;
0027     u32 paramlen;
0028     bool key_is_private;
0029     const char *id_type;
0030     const char *pkey_algo;
0031 };
0032 
0033 extern void public_key_free(struct public_key *key);
0034 
0035 /*
0036  * Public key cryptography signature data
0037  */
0038 struct public_key_signature {
0039     struct asymmetric_key_id *auth_ids[3];
0040     u8 *s;          /* Signature */
0041     u8 *digest;
0042     u32 s_size;     /* Number of bytes in signature */
0043     u32 digest_size;    /* Number of bytes in digest */
0044     const char *pkey_algo;
0045     const char *hash_algo;
0046     const char *encoding;
0047     const void *data;
0048     unsigned int data_size;
0049 };
0050 
0051 extern void public_key_signature_free(struct public_key_signature *sig);
0052 
0053 extern struct asymmetric_key_subtype public_key_subtype;
0054 
0055 struct key;
0056 struct key_type;
0057 union key_payload;
0058 
0059 extern int restrict_link_by_signature(struct key *dest_keyring,
0060                       const struct key_type *type,
0061                       const union key_payload *payload,
0062                       struct key *trust_keyring);
0063 
0064 extern int restrict_link_by_key_or_keyring(struct key *dest_keyring,
0065                        const struct key_type *type,
0066                        const union key_payload *payload,
0067                        struct key *trusted);
0068 
0069 extern int restrict_link_by_key_or_keyring_chain(struct key *trust_keyring,
0070                          const struct key_type *type,
0071                          const union key_payload *payload,
0072                          struct key *trusted);
0073 
0074 extern int query_asymmetric_key(const struct kernel_pkey_params *,
0075                 struct kernel_pkey_query *);
0076 
0077 extern int encrypt_blob(struct kernel_pkey_params *, const void *, void *);
0078 extern int decrypt_blob(struct kernel_pkey_params *, const void *, void *);
0079 extern int create_signature(struct kernel_pkey_params *, const void *, void *);
0080 extern int verify_signature(const struct key *,
0081                 const struct public_key_signature *);
0082 
0083 int public_key_verify_signature(const struct public_key *pkey,
0084                 const struct public_key_signature *sig);
0085 
0086 #endif /* _LINUX_PUBLIC_KEY_H */