Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /* Asymmetric public-key cryptography key subtype
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 _KEYS_ASYMMETRIC_SUBTYPE_H
0011 #define _KEYS_ASYMMETRIC_SUBTYPE_H
0012 
0013 #include <linux/seq_file.h>
0014 #include <keys/asymmetric-type.h>
0015 
0016 struct kernel_pkey_query;
0017 struct kernel_pkey_params;
0018 struct public_key_signature;
0019 
0020 /*
0021  * Keys of this type declare a subtype that indicates the handlers and
0022  * capabilities.
0023  */
0024 struct asymmetric_key_subtype {
0025     struct module       *owner;
0026     const char      *name;
0027     unsigned short      name_len;   /* length of name */
0028 
0029     /* Describe a key of this subtype for /proc/keys */
0030     void (*describe)(const struct key *key, struct seq_file *m);
0031 
0032     /* Destroy a key of this subtype */
0033     void (*destroy)(void *payload_crypto, void *payload_auth);
0034 
0035     int (*query)(const struct kernel_pkey_params *params,
0036              struct kernel_pkey_query *info);
0037 
0038     /* Encrypt/decrypt/sign data */
0039     int (*eds_op)(struct kernel_pkey_params *params,
0040               const void *in, void *out);
0041 
0042     /* Verify the signature on a key of this subtype (optional) */
0043     int (*verify_signature)(const struct key *key,
0044                 const struct public_key_signature *sig);
0045 };
0046 
0047 /**
0048  * asymmetric_key_subtype - Get the subtype from an asymmetric key
0049  * @key: The key of interest.
0050  *
0051  * Retrieves and returns the subtype pointer of the asymmetric key from the
0052  * type-specific data attached to the key.
0053  */
0054 static inline
0055 struct asymmetric_key_subtype *asymmetric_key_subtype(const struct key *key)
0056 {
0057     return key->payload.data[asym_subtype];
0058 }
0059 
0060 #endif /* _KEYS_ASYMMETRIC_SUBTYPE_H */