6sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget*/translations/zh_CN/crypto/asymmetric-keysmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/zh_TW/crypto/asymmetric-keysmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/it_IT/crypto/asymmetric-keysmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/ja_JP/crypto/asymmetric-keysmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/ko_KR/crypto/asymmetric-keysmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/sp_SP/crypto/asymmetric-keysmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhD/var/lib/git/docbuild/linux/Documentation/crypto/asymmetric-keys.rsthKubhsection)}(hhh](htitle)}(h-Asymmetric / Public-key Cryptography Key Typeh]h-Asymmetric / Public-key Cryptography Key Type}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hContents: - Overview. - Key identification. - Accessing asymmetric keys. - Signature verification. - Asymmetric key subtypes. - Instantiation data parsers. - Keyring link restrictions.h]hContents: - Overview. - Key identification. - Accessing asymmetric keys. - Signature verification. - Asymmetric key subtypes. - Instantiation data parsers. - Keyring link restrictions.}hhsbah}(h]h ]h"]h$]h&]hhuh1hhhhhhhhKubh)}(hhh](h)}(hOverviewh]hOverview}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hThe "asymmetric" key type is designed to be a container for the keys used in public-key cryptography, without imposing any particular restrictions on the form or mechanism of the cryptography or form of the key.h]hThe “asymmetric” key type is designed to be a container for the keys used in public-key cryptography, without imposing any particular restrictions on the form or mechanism of the cryptography or form of the key.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hThe asymmetric key is given a subtype that defines what sort of data is associated with the key and provides operations to describe and destroy it. However, no requirement is made that the key data actually be stored in the key.h]hThe asymmetric key is given a subtype that defines what sort of data is associated with the key and provides operations to describe and destroy it. However, no requirement is made that the key data actually be stored in the key.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXWA completely in-kernel key retention and operation subtype can be defined, but it would also be possible to provide access to cryptographic hardware (such as a TPM) that might be used to both retain the relevant key and perform operations using that key. In such a case, the asymmetric key would then merely be an interface to the TPM driver.h]hXWA completely in-kernel key retention and operation subtype can be defined, but it would also be possible to provide access to cryptographic hardware (such as a TPM) that might be used to both retain the relevant key and perform operations using that key. In such a case, the asymmetric key would then merely be an interface to the TPM driver.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hX/Also provided is the concept of a data parser. Data parsers are responsible for extracting information from the blobs of data passed to the instantiation function. The first data parser that recognises the blob gets to set the subtype of the key and define the operations that can be done on that key.h]hX/Also provided is the concept of a data parser. Data parsers are responsible for extracting information from the blobs of data passed to the instantiation function. The first data parser that recognises the blob gets to set the subtype of the key and define the operations that can be done on that key.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK$hhhhubh)}(hA data parser may interpret the data blob as containing the bits representing a key, or it may interpret it as a reference to a key held somewhere else in the system (for example, a TPM).h]hA data parser may interpret the data blob as containing the bits representing a key, or it may interpret it as a reference to a key held somewhere else in the system (for example, a TPM).}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK)hhhhubeh}(h]overviewah ]h"]overviewah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hKey Identificationh]hKey Identification}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj8hhhhhK/ubh)}(hIf a key is added with an empty name, the instantiation data parsers are given the opportunity to pre-parse a key and to determine the description the key should be given from the content of the key.h]hIf a key is added with an empty name, the instantiation data parsers are given the opportunity to pre-parse a key and to determine the description the key should be given from the content of the key.}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK1hj8hhubh)}(hThis can then be used to refer to the key, either by complete match or by partial match. The key type may also use other criteria to refer to a key.h]hThis can then be used to refer to the key, either by complete match or by partial match. The key type may also use other criteria to refer to a key.}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK5hj8hhubh)}(hThe asymmetric key type's match function can then perform a wider range of comparisons than just the straightforward comparison of the description with the criterion string:h]hThe asymmetric key type’s match function can then perform a wider range of comparisons than just the straightforward comparison of the description with the criterion string:}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK8hj8hhubh block_quote)}(hXu1) If the criterion string is of the form "id:" then the match function will examine a key's fingerprint to see if the hex digits given after the "id:" match the tail. For instance:: keyctl search @s asymmetric id:5acc2142 will match a key with fingerprint:: 1A00 2040 7601 7889 DE11 882C 3823 04AD 5ACC 2142 2) If the criterion string is of the form ":" then the match will match the ID as in (1), but with the added restriction that only keys of the specified subtype (e.g. tpm) will be matched. For instance:: keyctl search @s asymmetric tpm:5acc2142 h]henumerated_list)}(hhh](h list_item)}(hXHIf the criterion string is of the form "id:" then the match function will examine a key's fingerprint to see if the hex digits given after the "id:" match the tail. For instance:: keyctl search @s asymmetric id:5acc2142 will match a key with fingerprint:: 1A00 2040 7601 7889 DE11 882C 3823 04AD 5ACC 2142 h](h)}(hIf the criterion string is of the form "id:" then the match function will examine a key's fingerprint to see if the hex digits given after the "id:" match the tail. For instance::h]hIf the criterion string is of the form “id:” then the match function will examine a key’s fingerprint to see if the hex digits given after the “id:” match the tail. For instance:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK:" then the match will match the ID as in (1), but with the added restriction that only keys of the specified subtype (e.g. tpm) will be matched. For instance:: keyctl search @s asymmetric tpm:5acc2142 h](h)}(hIf the criterion string is of the form ":" then the match will match the ID as in (1), but with the added restriction that only keys of the specified subtype (e.g. tpm) will be matched. For instance::h]hIf the criterion string is of the form “:” then the match will match the ID as in (1), but with the added restriction that only keys of the specified subtype (e.g. tpm) will be matched. For instance:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKFhjubj)}(h(keyctl search @s asymmetric tpm:5acc2142h]h(keyctl search @s asymmetric tpm:5acc2142}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKKhjubeh}(h]h ]h"]h$]h&]uh1j~hj{ubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix)uh1jyhjuubah}(h]h ]h"]h$]h&]uh1jshhhKh]h#include }hj>sbah}(h]h ]h"]h$]h&]hhuh1jhhhKYhjhhubh)}(hThis gives access to functions for dealing with asymmetric / public keys. Three enums are defined there for representing public-key cryptography algorithms::h]hThis gives access to functions for dealing with asymmetric / public keys. Three enums are defined there for representing public-key cryptography algorithms:}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hjhhubj)}(henum pkey_algoh]henum pkey_algo}hjZsbah}(h]h ]h"]h$]h&]hhuh1jhhhK_hjhhubh)}(h!digest algorithms used by those::h]h digest algorithms used by those:}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKahjhhubj)}(henum pkey_hash_algoh]henum pkey_hash_algo}hjvsbah}(h]h ]h"]h$]h&]hhuh1jhhhKchjhhubh)}(h$and key identifier representations::h]h#and key identifier representations:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKehjhhubj)}(henum pkey_id_typeh]henum pkey_id_type}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKghjhhubh)}(hX#Note that the key type representation types are required because key identifiers from different standards aren't necessarily compatible. For instance, PGP generates key identifiers by hashing the key data plus some PGP-specific metadata, whereas X.509 has arbitrary certificate identifiers.h]hX%Note that the key type representation types are required because key identifiers from different standards aren’t necessarily compatible. For instance, PGP generates key identifiers by hashing the key data plus some PGP-specific metadata, whereas X.509 has arbitrary certificate identifiers.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKihjhhubh)}(h&The operations defined upon a key are:h]h&The operations defined upon a key are:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKnhjhhubjt)}(h1) Signature verification. h]jz)}(hhh]j)}(hSignature verification. h]h)}(hSignature verification.h]hSignature verification.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKphjubah}(h]h ]h"]h$]h&]uh1j~hjubah}(h]h ]h"]h$]h&]jjjhjjuh1jyhjubah}(h]h ]h"]h$]h&]uh1jshhhKphjhhubh)}(hOther operations are possible (such as encryption) with the same key data required for verification, but not currently supported, and others (eg. decryption and signature generation) require extra key data.h]hOther operations are possible (such as encryption) with the same key data required for verification, but not currently supported, and others (eg. decryption and signature generation) require extra key data.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKrhjhhubh)}(hhh](h)}(hSignature Verificationh]hSignature Verification}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKxubh)}(hAn operation is provided to perform cryptographic signature verification, using an asymmetric key to provide or to provide access to the public key::h]hAn operation is provided to perform cryptographic signature verification, using an asymmetric key to provide or to provide access to the public key:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhjhhubj)}(hiint verify_signature(const struct key *key, const struct public_key_signature *sig);h]hiint verify_signature(const struct key *key, const struct public_key_signature *sig);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhK}hjhhubh)}(hThe caller must have already obtained the key from some source and can then use it to check the signature. The caller must have parsed the signature and transferred the relevant bits to the structure pointed to by sig::h]hThe caller must have already obtained the key from some source and can then use it to check the signature. The caller must have parsed the signature and transferred the relevant bits to the structure pointed to by sig:}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hstruct public_key_signature { u8 *digest; u8 digest_size; enum pkey_hash_algo pkey_hash_algo : 8; u8 nr_mpi; union { MPI mpi[2]; ... }; };h]hstruct public_key_signature { u8 *digest; u8 digest_size; enum pkey_hash_algo pkey_hash_algo : 8; u8 nr_mpi; union { MPI mpi[2]; ... }; };}hj0sbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjhhubh)}(hThe algorithm used must be noted in sig->pkey_hash_algo, and all the MPIs that make up the actual signature must be stored in sig->mpi[] and the count of MPIs placed in sig->nr_mpi.h]hThe algorithm used must be noted in sig->pkey_hash_algo, and all the MPIs that make up the actual signature must be stored in sig->mpi[] and the count of MPIs placed in sig->nr_mpi.}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hIn addition, the data must have been digested by the caller and the resulting hash must be pointed to by sig->digest and the size of the hash be placed in sig->digest_size.h]hIn addition, the data must have been digested by the caller and the resulting hash must be pointed to by sig->digest and the size of the hash be placed in sig->digest_size.}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXThe function will return 0 upon success or -EKEYREJECTED if the signature doesn't match.h]hZThe function will return 0 upon success or -EKEYREJECTED if the signature doesn’t match.}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXvThe function may also return -ENOTSUPP if an unsupported public-key algorithm or public-key/hash algorithm combination is specified or the key doesn't support the operation; -EBADMSG or -ERANGE if some of the parameters have weird data; or -ENOMEM if an allocation can't be performed. -EINVAL can be returned if the key argument is the wrong type or is incompletely set up.h]hXzThe function may also return -ENOTSUPP if an unsupported public-key algorithm or public-key/hash algorithm combination is specified or the key doesn’t support the operation; -EBADMSG or -ERANGE if some of the parameters have weird data; or -ENOMEM if an allocation can’t be performed. -EINVAL can be returned if the key argument is the wrong type or is incompletely set up.}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]signature-verificationah ]h"]signature verificationah$]h&]uh1hhjhhhhhKxubeh}(h]accessing-asymmetric-keysah ]h"]accessing asymmetric keysah$]h&]uh1hhhhhhhhKTubh)}(hhh](h)}(hAsymmetric Key Subtypesh]hAsymmetric Key Subtypes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hAsymmetric keys have a subtype that defines the set of operations that can be performed on that key and that determines what data is attached as the key payload. The payload format is entirely at the whim of the subtype.h]hAsymmetric keys have a subtype that defines the set of operations that can be performed on that key and that determines what data is attached as the key payload. The payload format is entirely at the whim of the subtype.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe subtype is selected by the key data parser and the parser must initialise the data required for it. The asymmetric key retains a reference on the subtype module.h]hThe subtype is selected by the key data parser and the parser must initialise the data required for it. The asymmetric key retains a reference on the subtype module.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h2The subtype definition structure can be found in::h]h1The subtype definition structure can be found in:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h$#include h]h$#include }hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjhhubh)}(hand looks like the following::h]hand looks like the following:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hX>struct asymmetric_key_subtype { struct module *owner; const char *name; void (*describe)(const struct key *key, struct seq_file *m); void (*destroy)(void *payload); int (*query)(const struct kernel_pkey_params *params, struct kernel_pkey_query *info); int (*eds_op)(struct kernel_pkey_params *params, const void *in, void *out); int (*verify_signature)(const struct key *key, const struct public_key_signature *sig); };h]hX>struct asymmetric_key_subtype { struct module *owner; const char *name; void (*describe)(const struct key *key, struct seq_file *m); void (*destroy)(void *payload); int (*query)(const struct kernel_pkey_params *params, struct kernel_pkey_query *info); int (*eds_op)(struct kernel_pkey_params *params, const void *in, void *out); int (*verify_signature)(const struct key *key, const struct public_key_signature *sig); };}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjhhubh)}(hFAsymmetric keys point to this with their payload[asym_subtype] member.h]hFAsymmetric keys point to this with their payload[asym_subtype] member.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe owner and name fields should be set to the owning module and the name of the subtype. Currently, the name is only used for print statements.h]hThe owner and name fields should be set to the owning module and the name of the subtype. Currently, the name is only used for print statements.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h8There are a number of operations defined by the subtype:h]h8There are a number of operations defined by the subtype:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubjt)}(hX1) describe(). Mandatory. This allows the subtype to display something in /proc/keys against the key. For instance the name of the public key algorithm type could be displayed. The key type will display the tail of the key identity string after this. 2) destroy(). Mandatory. This should free the memory associated with the key. The asymmetric key will look after freeing the fingerprint and releasing the reference on the subtype module. 3) query(). Mandatory. This is a function for querying the capabilities of a key. 4) eds_op(). Optional. This is the entry point for the encryption, decryption and signature creation operations (which are distinguished by the operation ID in the parameter struct). The subtype may do anything it likes to implement an operation, including offloading to hardware. 5) verify_signature(). Optional. This is the entry point for signature verification. The subtype may do anything it likes to implement an operation, including offloading to hardware. h]jz)}(hhh](j)}(hdescribe(). Mandatory. This allows the subtype to display something in /proc/keys against the key. For instance the name of the public key algorithm type could be displayed. The key type will display the tail of the key identity string after this. h](h)}(h describe().h]h describe().}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hMandatory. This allows the subtype to display something in /proc/keys against the key. For instance the name of the public key algorithm type could be displayed. The key type will display the tail of the key identity string after this.h]hMandatory. This allows the subtype to display something in /proc/keys against the key. For instance the name of the public key algorithm type could be displayed. The key type will display the tail of the key identity string after this.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j~hjubj)}(hdestroy(). Mandatory. This should free the memory associated with the key. The asymmetric key will look after freeing the fingerprint and releasing the reference on the subtype module. h](h)}(h destroy().h]h destroy().}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjBubh)}(hMandatory. This should free the memory associated with the key. The asymmetric key will look after freeing the fingerprint and releasing the reference on the subtype module.h]hMandatory. This should free the memory associated with the key. The asymmetric key will look after freeing the fingerprint and releasing the reference on the subtype module.}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjBubeh}(h]h ]h"]h$]h&]uh1j~hjubj)}(hQquery(). Mandatory. This is a function for querying the capabilities of a key. h](h)}(hquery().h]hquery().}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhubh)}(hFMandatory. This is a function for querying the capabilities of a key.h]hFMandatory. This is a function for querying the capabilities of a key.}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhubeh}(h]h ]h"]h$]h&]uh1j~hjubj)}(hXeds_op(). Optional. This is the entry point for the encryption, decryption and signature creation operations (which are distinguished by the operation ID in the parameter struct). The subtype may do anything it likes to implement an operation, including offloading to hardware. h](h)}(h eds_op().h]h eds_op().}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hX Optional. This is the entry point for the encryption, decryption and signature creation operations (which are distinguished by the operation ID in the parameter struct). The subtype may do anything it likes to implement an operation, including offloading to hardware.h]hX Optional. This is the entry point for the encryption, decryption and signature creation operations (which are distinguished by the operation ID in the parameter struct). The subtype may do anything it likes to implement an operation, including offloading to hardware.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j~hjubj)}(hverify_signature(). Optional. This is the entry point for signature verification. The subtype may do anything it likes to implement an operation, including offloading to hardware. h](h)}(hverify_signature().h]hverify_signature().}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hOptional. This is the entry point for signature verification. The subtype may do anything it likes to implement an operation, including offloading to hardware.h]hOptional. This is the entry point for signature verification. The subtype may do anything it likes to implement an operation, including offloading to hardware.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j~hjubeh}(h]h ]h"]h$]h&]jjjhjjuh1jyhjubah}(h]h ]h"]h$]h&]uh1jshhhKhjhhubeh}(h]asymmetric-key-subtypesah ]h"]asymmetric key subtypesah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hInstantiation Data Parsersh]hInstantiation Data Parsers}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXThe asymmetric key type doesn't generally want to store or to deal with a raw blob of data that holds the key data. It would have to parse it and error check it each time it wanted to use it. Further, the contents of the blob may have various checks that can be performed on it (eg. self-signatures, validity dates) and may contain useful data about the key (identifiers, capabilities).h]hXThe asymmetric key type doesn’t generally want to store or to deal with a raw blob of data that holds the key data. It would have to parse it and error check it each time it wanted to use it. Further, the contents of the blob may have various checks that can be performed on it (eg. self-signatures, validity dates) and may contain useful data about the key (identifiers, capabilities).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hfAlso, the blob may represent a pointer to some hardware containing the key rather than the key itself.h]hfAlso, the blob may represent a pointer to some hardware containing the key rather than the key itself.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hHExamples of blob formats for which parsers could be implemented include:h]hHExamples of blob formats for which parsers could be implemented include:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubjt)}(h- OpenPGP packet stream [RFC 4880]. - X.509 ASN.1 stream. - Pointer to TPM key. - Pointer to UEFI key. - PKCS#8 private key [RFC 5208]. - PKCS#5 encrypted private key [RFC 2898]. h]h bullet_list)}(hhh](j)}(h!OpenPGP packet stream [RFC 4880].h]h)}(hj4h]h!OpenPGP packet stream [RFC 4880].}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj2ubah}(h]h ]h"]h$]h&]uh1j~hj/ubj)}(hX.509 ASN.1 stream.h]h)}(hjKh]hX.509 ASN.1 stream.}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjIubah}(h]h ]h"]h$]h&]uh1j~hj/ubj)}(hPointer to TPM key.h]h)}(hjbh]hPointer to TPM key.}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj`ubah}(h]h ]h"]h$]h&]uh1j~hj/ubj)}(hPointer to UEFI key.h]h)}(hjyh]hPointer to UEFI key.}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjwubah}(h]h ]h"]h$]h&]uh1j~hj/ubj)}(hPKCS#8 private key [RFC 5208].h]h)}(hjh]hPKCS#8 private key [RFC 5208].}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j~hj/ubj)}(h)PKCS#5 encrypted private key [RFC 2898]. h]h)}(h(PKCS#5 encrypted private key [RFC 2898].h]h(PKCS#5 encrypted private key [RFC 2898].}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j~hj/ubeh}(h]h ]h"]h$]h&]bullet-uh1j-hhhKhj)ubah}(h]h ]h"]h$]h&]uh1jshhhKhjhhubh)}(h\During key instantiation each parser in the list is tried until one doesn't return -EBADMSG.h]h^During key instantiation each parser in the list is tried until one doesn’t return -EBADMSG.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h1The parser definition structure can be found in::h]h0The parser definition structure can be found in:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h##include h]h##include }hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhKhjhhubh)}(hand looks like the following::h]hand looks like the following:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(hstruct asymmetric_key_parser { struct module *owner; const char *name; int (*parse)(struct key_preparsed_payload *prep); };h]hstruct asymmetric_key_parser { struct module *owner; const char *name; int (*parse)(struct key_preparsed_payload *prep); };}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhMhjhhubh)}(hXThe owner and name fields should be set to the owning module and the name of the parser.h]hXThe owner and name fields should be set to the owning module and the name of the parser.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubh)}(hVThere is currently only a single operation defined by the parser, and it is mandatory:h]hVThere is currently only a single operation defined by the parser, and it is mandatory:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubjt)}(hX1) parse(). This is called to preparse the key from the key creation and update paths. In particular, it is called during the key creation _before_ a key is allocated, and as such, is permitted to provide the key's description in the case that the caller declines to do so. The caller passes a pointer to the following struct with all of the fields cleared, except for data, datalen and quotalen [see Documentation/security/keys/core.rst]:: struct key_preparsed_payload { char *description; void *payload[4]; const void *data; size_t datalen; size_t quotalen; }; The instantiation data is in a blob pointed to by data and is datalen in size. The parse() function is not permitted to change these two values at all, and shouldn't change any of the other values _unless_ they are recognise the blob format and will not return -EBADMSG to indicate it is not theirs. If the parser is happy with the blob, it should propose a description for the key and attach it to ->description, ->payload[asym_subtype] should be set to point to the subtype to be used, ->payload[asym_crypto] should be set to point to the initialised data for that subtype, ->payload[asym_key_ids] should point to one or more hex fingerprints and quotalen should be updated to indicate how much quota this key should account for. When clearing up, the data attached to ->payload[asym_key_ids] and ->description will be kfree()'d and the data attached to ->payload[asm_crypto] will be passed to the subtype's ->destroy() method to be disposed of. A module reference for the subtype pointed to by ->payload[asym_subtype] will be put. If the data format is not recognised, -EBADMSG should be returned. If it is recognised, but the key cannot for some reason be set up, some other negative error code should be returned. On success, 0 should be returned. The key's fingerprint string may be partially matched upon. For a public-key algorithm such as RSA and DSA this will likely be a printable hex version of the key's fingerprint. h]jz)}(hhh]j)}(hX>parse(). This is called to preparse the key from the key creation and update paths. In particular, it is called during the key creation _before_ a key is allocated, and as such, is permitted to provide the key's description in the case that the caller declines to do so. The caller passes a pointer to the following struct with all of the fields cleared, except for data, datalen and quotalen [see Documentation/security/keys/core.rst]:: struct key_preparsed_payload { char *description; void *payload[4]; const void *data; size_t datalen; size_t quotalen; }; The instantiation data is in a blob pointed to by data and is datalen in size. The parse() function is not permitted to change these two values at all, and shouldn't change any of the other values _unless_ they are recognise the blob format and will not return -EBADMSG to indicate it is not theirs. If the parser is happy with the blob, it should propose a description for the key and attach it to ->description, ->payload[asym_subtype] should be set to point to the subtype to be used, ->payload[asym_crypto] should be set to point to the initialised data for that subtype, ->payload[asym_key_ids] should point to one or more hex fingerprints and quotalen should be updated to indicate how much quota this key should account for. When clearing up, the data attached to ->payload[asym_key_ids] and ->description will be kfree()'d and the data attached to ->payload[asm_crypto] will be passed to the subtype's ->destroy() method to be disposed of. A module reference for the subtype pointed to by ->payload[asym_subtype] will be put. If the data format is not recognised, -EBADMSG should be returned. If it is recognised, but the key cannot for some reason be set up, some other negative error code should be returned. On success, 0 should be returned. The key's fingerprint string may be partially matched upon. For a public-key algorithm such as RSA and DSA this will likely be a printable hex version of the key's fingerprint. h](h)}(hparse().h]hparse().}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4ubh)}(hXThis is called to preparse the key from the key creation and update paths. In particular, it is called during the key creation _before_ a key is allocated, and as such, is permitted to provide the key's description in the case that the caller declines to do so.h]hXThis is called to preparse the key from the key creation and update paths. In particular, it is called during the key creation _before_ a key is allocated, and as such, is permitted to provide the key’s description in the case that the caller declines to do so.}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4ubh)}(hThe caller passes a pointer to the following struct with all of the fields cleared, except for data, datalen and quotalen [see Documentation/security/keys/core.rst]::h]hThe caller passes a pointer to the following struct with all of the fields cleared, except for data, datalen and quotalen [see Documentation/security/keys/core.rst]:}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj4ubj)}(hstruct key_preparsed_payload { char *description; void *payload[4]; const void *data; size_t datalen; size_t quotalen; };h]hstruct key_preparsed_payload { char *description; void *payload[4]; const void *data; size_t datalen; size_t quotalen; };}hjbsbah}(h]h ]h"]h$]h&]hhuh1jhhhMhj4ubh)}(hX,The instantiation data is in a blob pointed to by data and is datalen in size. The parse() function is not permitted to change these two values at all, and shouldn't change any of the other values _unless_ they are recognise the blob format and will not return -EBADMSG to indicate it is not theirs.h]hX.The instantiation data is in a blob pointed to by data and is datalen in size. The parse() function is not permitted to change these two values at all, and shouldn’t change any of the other values _unless_ they are recognise the blob format and will not return -EBADMSG to indicate it is not theirs.}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM#hj4ubh)}(hXIf the parser is happy with the blob, it should propose a description for the key and attach it to ->description, ->payload[asym_subtype] should be set to point to the subtype to be used, ->payload[asym_crypto] should be set to point to the initialised data for that subtype, ->payload[asym_key_ids] should point to one or more hex fingerprints and quotalen should be updated to indicate how much quota this key should account for.h]hXIf the parser is happy with the blob, it should propose a description for the key and attach it to ->description, ->payload[asym_subtype] should be set to point to the subtype to be used, ->payload[asym_crypto] should be set to point to the initialised data for that subtype, ->payload[asym_key_ids] should point to one or more hex fingerprints and quotalen should be updated to indicate how much quota this key should account for.}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM)hj4ubh)}(hX.When clearing up, the data attached to ->payload[asym_key_ids] and ->description will be kfree()'d and the data attached to ->payload[asm_crypto] will be passed to the subtype's ->destroy() method to be disposed of. A module reference for the subtype pointed to by ->payload[asym_subtype] will be put.h]hX2When clearing up, the data attached to ->payload[asym_key_ids] and ->description will be kfree()’d and the data attached to ->payload[asm_crypto] will be passed to the subtype’s ->destroy() method to be disposed of. A module reference for the subtype pointed to by ->payload[asym_subtype] will be put.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM1hj4ubh)}(hIf the data format is not recognised, -EBADMSG should be returned. If it is recognised, but the key cannot for some reason be set up, some other negative error code should be returned. On success, 0 should be returned.h]hIf the data format is not recognised, -EBADMSG should be returned. If it is recognised, but the key cannot for some reason be set up, some other negative error code should be returned. On success, 0 should be returned.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM8hj4ubh)}(hThe key's fingerprint string may be partially matched upon. For a public-key algorithm such as RSA and DSA this will likely be a printable hex version of the key's fingerprint.h]hThe key’s fingerprint string may be partially matched upon. For a public-key algorithm such as RSA and DSA this will likely be a printable hex version of the key’s fingerprint.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM<hj4ubeh}(h]h ]h"]h$]h&]uh1j~hj1ubah}(h]h ]h"]h$]h&]jjjhjjuh1jyhj-ubah}(h]h ]h"]h$]h&]uh1jshhhMhjhhubh)}(h;Functions are provided to register and unregister parsers::h]h:Functions are provided to register and unregister parsers:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM@hjhhubj)}(hint register_asymmetric_key_parser(struct asymmetric_key_parser *parser); void unregister_asymmetric_key_parser(struct asymmetric_key_parser *subtype);h]hint register_asymmetric_key_parser(struct asymmetric_key_parser *parser); void unregister_asymmetric_key_parser(struct asymmetric_key_parser *subtype);}hjsbah}(h]h ]h"]h$]h&]hhuh1jhhhMBhjhhubh)}(hlParsers may not have the same name. The names are otherwise only used for displaying in debugging messages.h]hlParsers may not have the same name. The names are otherwise only used for displaying in debugging messages.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMEhjhhubeh}(h]instantiation-data-parsersah ]h"]instantiation data parsersah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hKeyring Link Restrictionsh]hKeyring Link Restrictions}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMJubh)}(hKeyrings created from userspace using add_key can be configured to check the signature of the key being linked. Keys without a valid signature are not allowed to link.h]hKeyrings created from userspace using add_key can be configured to check the signature of the key being linked. Keys without a valid signature are not allowed to link.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMLhjhhubh)}(h*Several restriction methods are available:h]h*Several restriction methods are available:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMPhjhhubjt)}(hX1) Restrict using the kernel builtin trusted keyring - Option string used with KEYCTL_RESTRICT_KEYRING: - "builtin_trusted" The kernel builtin trusted keyring will be searched for the signing key. If the builtin trusted keyring is not configured, all links will be rejected. The ca_keys kernel parameter also affects which keys are used for signature verification. 2) Restrict using the kernel builtin and secondary trusted keyrings - Option string used with KEYCTL_RESTRICT_KEYRING: - "builtin_and_secondary_trusted" The kernel builtin and secondary trusted keyrings will be searched for the signing key. If the secondary trusted keyring is not configured, this restriction will behave like the "builtin_trusted" option. The ca_keys kernel parameter also affects which keys are used for signature verification. 3) Restrict using a separate key or keyring - Option string used with KEYCTL_RESTRICT_KEYRING: - "key_or_keyring:[:chain]" Whenever a key link is requested, the link will only succeed if the key being linked is signed by one of the designated keys. This key may be specified directly by providing a serial number for one asymmetric key, or a group of keys may be searched for the signing key by providing the serial number for a keyring. When the "chain" option is provided at the end of the string, the keys within the destination keyring will also be searched for signing keys. This allows for verification of certificate chains by adding each certificate in order (starting closest to the root) to a keyring. For instance, one keyring can be populated with links to a set of root certificates, with a separate, restricted keyring set up for each certificate chain to be validated:: # Create and populate a keyring for root certificates root_id=`keyctl add keyring root-certs "" @s` keyctl padd asymmetric "" $root_id < root1.cert keyctl padd asymmetric "" $root_id < root2.cert # Create and restrict a keyring for the certificate chain chain_id=`keyctl add keyring chain "" @s` keyctl restrict_keyring $chain_id asymmetric key_or_keyring:$root_id:chain # Attempt to add each certificate in the chain, starting with the # certificate closest to the root. keyctl padd asymmetric "" $chain_id < intermediateA.cert keyctl padd asymmetric "" $chain_id < intermediateB.cert keyctl padd asymmetric "" $chain_id < end-entity.cert If the final end-entity certificate is successfully added to the "chain" keyring, we can be certain that it has a valid signing chain going back to one of the root certificates. A single keyring can be used to verify a chain of signatures by restricting the keyring after linking the root certificate:: # Create a keyring for the certificate chain and add the root chain2_id=`keyctl add keyring chain2 "" @s` keyctl padd asymmetric "" $chain2_id < root1.cert # Restrict the keyring that already has root1.cert linked. The cert # will remain linked by the keyring. keyctl restrict_keyring $chain2_id asymmetric key_or_keyring:0:chain # Attempt to add each certificate in the chain, starting with the # certificate closest to the root. keyctl padd asymmetric "" $chain2_id < intermediateA.cert keyctl padd asymmetric "" $chain2_id < intermediateB.cert keyctl padd asymmetric "" $chain2_id < end-entity.cert If the final end-entity certificate is successfully added to the "chain2" keyring, we can be certain that there is a valid signing chain going back to the root certificate that was added before the keyring was restricted. h]jz)}(hhh](j)}(hXoRestrict using the kernel builtin trusted keyring - Option string used with KEYCTL_RESTRICT_KEYRING: - "builtin_trusted" The kernel builtin trusted keyring will be searched for the signing key. If the builtin trusted keyring is not configured, all links will be rejected. The ca_keys kernel parameter also affects which keys are used for signature verification. h](h)}(h1Restrict using the kernel builtin trusted keyringh]h1Restrict using the kernel builtin trusted keyring}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMRhj.ubj.)}(hhh]j)}(hEOption string used with KEYCTL_RESTRICT_KEYRING: - "builtin_trusted" h]h)}(hDOption string used with KEYCTL_RESTRICT_KEYRING: - "builtin_trusted"h]hHOption string used with KEYCTL_RESTRICT_KEYRING: - “builtin_trusted”}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMThjCubah}(h]h ]h"]h$]h&]uh1j~hj@ubah}(h]h ]h"]h$]h&]jjuh1j-hhhMThj.ubh)}(hThe kernel builtin trusted keyring will be searched for the signing key. If the builtin trusted keyring is not configured, all links will be rejected. The ca_keys kernel parameter also affects which keys are used for signature verification.h]hThe kernel builtin trusted keyring will be searched for the signing key. If the builtin trusted keyring is not configured, all links will be rejected. The ca_keys kernel parameter also affects which keys are used for signature verification.}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMWhj.ubeh}(h]h ]h"]h$]h&]uh1j~hj+ubj)}(hXRestrict using the kernel builtin and secondary trusted keyrings - Option string used with KEYCTL_RESTRICT_KEYRING: - "builtin_and_secondary_trusted" The kernel builtin and secondary trusted keyrings will be searched for the signing key. If the secondary trusted keyring is not configured, this restriction will behave like the "builtin_trusted" option. The ca_keys kernel parameter also affects which keys are used for signature verification. h](h)}(h@Restrict using the kernel builtin and secondary trusted keyringsh]h@Restrict using the kernel builtin and secondary trusted keyrings}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM\hjuubj.)}(hhh]j)}(hSOption string used with KEYCTL_RESTRICT_KEYRING: - "builtin_and_secondary_trusted" h]h)}(hROption string used with KEYCTL_RESTRICT_KEYRING: - "builtin_and_secondary_trusted"h]hVOption string used with KEYCTL_RESTRICT_KEYRING: - “builtin_and_secondary_trusted”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM^hjubah}(h]h ]h"]h$]h&]uh1j~hjubah}(h]h ]h"]h$]h&]jjuh1j-hhhM^hjuubh)}(hX'The kernel builtin and secondary trusted keyrings will be searched for the signing key. If the secondary trusted keyring is not configured, this restriction will behave like the "builtin_trusted" option. The ca_keys kernel parameter also affects which keys are used for signature verification.h]hX+The kernel builtin and secondary trusted keyrings will be searched for the signing key. If the secondary trusted keyring is not configured, this restriction will behave like the “builtin_trusted” option. The ca_keys kernel parameter also affects which keys are used for signature verification.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMahjuubeh}(h]h ]h"]h$]h&]uh1j~hj+ubj)}(hX Restrict using a separate key or keyring - Option string used with KEYCTL_RESTRICT_KEYRING: - "key_or_keyring:[:chain]" Whenever a key link is requested, the link will only succeed if the key being linked is signed by one of the designated keys. This key may be specified directly by providing a serial number for one asymmetric key, or a group of keys may be searched for the signing key by providing the serial number for a keyring. When the "chain" option is provided at the end of the string, the keys within the destination keyring will also be searched for signing keys. This allows for verification of certificate chains by adding each certificate in order (starting closest to the root) to a keyring. For instance, one keyring can be populated with links to a set of root certificates, with a separate, restricted keyring set up for each certificate chain to be validated:: # Create and populate a keyring for root certificates root_id=`keyctl add keyring root-certs "" @s` keyctl padd asymmetric "" $root_id < root1.cert keyctl padd asymmetric "" $root_id < root2.cert # Create and restrict a keyring for the certificate chain chain_id=`keyctl add keyring chain "" @s` keyctl restrict_keyring $chain_id asymmetric key_or_keyring:$root_id:chain # Attempt to add each certificate in the chain, starting with the # certificate closest to the root. keyctl padd asymmetric "" $chain_id < intermediateA.cert keyctl padd asymmetric "" $chain_id < intermediateB.cert keyctl padd asymmetric "" $chain_id < end-entity.cert If the final end-entity certificate is successfully added to the "chain" keyring, we can be certain that it has a valid signing chain going back to one of the root certificates. A single keyring can be used to verify a chain of signatures by restricting the keyring after linking the root certificate:: # Create a keyring for the certificate chain and add the root chain2_id=`keyctl add keyring chain2 "" @s` keyctl padd asymmetric "" $chain2_id < root1.cert # Restrict the keyring that already has root1.cert linked. The cert # will remain linked by the keyring. keyctl restrict_keyring $chain2_id asymmetric key_or_keyring:0:chain # Attempt to add each certificate in the chain, starting with the # certificate closest to the root. keyctl padd asymmetric "" $chain2_id < intermediateA.cert keyctl padd asymmetric "" $chain2_id < intermediateB.cert keyctl padd asymmetric "" $chain2_id < end-entity.cert If the final end-entity certificate is successfully added to the "chain2" keyring, we can be certain that there is a valid signing chain going back to the root certificate that was added before the keyring was restricted. h](h)}(h(Restrict using a separate key or keyringh]h(Restrict using a separate key or keyring}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMghjubj.)}(hhh]j)}(hkOption string used with KEYCTL_RESTRICT_KEYRING: - "key_or_keyring:[:chain]" h]h)}(hjOption string used with KEYCTL_RESTRICT_KEYRING: - "key_or_keyring:[:chain]"h]hnOption string used with KEYCTL_RESTRICT_KEYRING: - “key_or_keyring:[:chain]”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMihjubah}(h]h ]h"]h$]h&]uh1j~hjubah}(h]h ]h"]h$]h&]jjuh1j-hhhMihjubh)}(hX;Whenever a key link is requested, the link will only succeed if the key being linked is signed by one of the designated keys. This key may be specified directly by providing a serial number for one asymmetric key, or a group of keys may be searched for the signing key by providing the serial number for a keyring.h]hX;Whenever a key link is requested, the link will only succeed if the key being linked is signed by one of the designated keys. This key may be specified directly by providing a serial number for one asymmetric key, or a group of keys may be searched for the signing key by providing the serial number for a keyring.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMlhjubh)}(hXWhen the "chain" option is provided at the end of the string, the keys within the destination keyring will also be searched for signing keys. This allows for verification of certificate chains by adding each certificate in order (starting closest to the root) to a keyring. For instance, one keyring can be populated with links to a set of root certificates, with a separate, restricted keyring set up for each certificate chain to be validated::h]hXWhen the “chain” option is provided at the end of the string, the keys within the destination keyring will also be searched for signing keys. This allows for verification of certificate chains by adding each certificate in order (starting closest to the root) to a keyring. For instance, one keyring can be populated with links to a set of root certificates, with a separate, restricted keyring set up for each certificate chain to be validated:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMrhjubj)}(hX# Create and populate a keyring for root certificates root_id=`keyctl add keyring root-certs "" @s` keyctl padd asymmetric "" $root_id < root1.cert keyctl padd asymmetric "" $root_id < root2.cert # Create and restrict a keyring for the certificate chain chain_id=`keyctl add keyring chain "" @s` keyctl restrict_keyring $chain_id asymmetric key_or_keyring:$root_id:chain # Attempt to add each certificate in the chain, starting with the # certificate closest to the root. keyctl padd asymmetric "" $chain_id < intermediateA.cert keyctl padd asymmetric "" $chain_id < intermediateB.cert keyctl padd asymmetric "" $chain_id < end-entity.certh]hX# Create and populate a keyring for root certificates root_id=`keyctl add keyring root-certs "" @s` keyctl padd asymmetric "" $root_id < root1.cert keyctl padd asymmetric "" $root_id < root2.cert # Create and restrict a keyring for the certificate chain chain_id=`keyctl add keyring chain "" @s` keyctl restrict_keyring $chain_id asymmetric key_or_keyring:$root_id:chain # Attempt to add each certificate in the chain, starting with the # certificate closest to the root. keyctl padd asymmetric "" $chain_id < intermediateA.cert keyctl padd asymmetric "" $chain_id < intermediateB.cert keyctl padd asymmetric "" $chain_id < end-entity.cert}hj sbah}(h]h ]h"]h$]h&]hhuh1jhhhMzhjubh)}(hIf the final end-entity certificate is successfully added to the "chain" keyring, we can be certain that it has a valid signing chain going back to one of the root certificates.h]hIf the final end-entity certificate is successfully added to the “chain” keyring, we can be certain that it has a valid signing chain going back to one of the root certificates.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h|A single keyring can be used to verify a chain of signatures by restricting the keyring after linking the root certificate::h]h{A single keyring can be used to verify a chain of signatures by restricting the keyring after linking the root certificate:}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubj)}(hX\# Create a keyring for the certificate chain and add the root chain2_id=`keyctl add keyring chain2 "" @s` keyctl padd asymmetric "" $chain2_id < root1.cert # Restrict the keyring that already has root1.cert linked. The cert # will remain linked by the keyring. keyctl restrict_keyring $chain2_id asymmetric key_or_keyring:0:chain # Attempt to add each certificate in the chain, starting with the # certificate closest to the root. keyctl padd asymmetric "" $chain2_id < intermediateA.cert keyctl padd asymmetric "" $chain2_id < intermediateB.cert keyctl padd asymmetric "" $chain2_id < end-entity.certh]hX\# Create a keyring for the certificate chain and add the root chain2_id=`keyctl add keyring chain2 "" @s` keyctl padd asymmetric "" $chain2_id < root1.cert # Restrict the keyring that already has root1.cert linked. The cert # will remain linked by the keyring. keyctl restrict_keyring $chain2_id asymmetric key_or_keyring:0:chain # Attempt to add each certificate in the chain, starting with the # certificate closest to the root. keyctl padd asymmetric "" $chain2_id < intermediateA.cert keyctl padd asymmetric "" $chain2_id < intermediateB.cert keyctl padd asymmetric "" $chain2_id < end-entity.cert}hj5sbah}(h]h ]h"]h$]h&]hhuh1jhhhMhjubh)}(hIf the final end-entity certificate is successfully added to the "chain2" keyring, we can be certain that there is a valid signing chain going back to the root certificate that was added before the keyring was restricted.h]hIf the final end-entity certificate is successfully added to the “chain2” keyring, we can be certain that there is a valid signing chain going back to the root certificate that was added before the keyring was restricted.}(hjChhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubeh}(h]h ]h"]h$]h&]uh1j~hj+ubeh}(h]h ]h"]h$]h&]jjjhjjuh1jyhj'ubah}(h]h ]h"]h$]h&]uh1jshhhMRhjhhubh)}(hXIn all of these cases, if the signing key is found the signature of the key to be linked will be verified using the signing key. The requested key is added to the keyring only if the signature is successfully verified. -ENOKEY is returned if the parent certificate could not be found, or -EKEYREJECTED is returned if the signature check fails or the key is blacklisted. Other errors may be returned if the signature check could not be performed.h]hXIn all of these cases, if the signing key is found the signature of the key to be linked will be verified using the signing key. The requested key is added to the keyring only if the signature is successfully verified. -ENOKEY is returned if the parent certificate could not be found, or -EKEYREJECTED is returned if the signature check fails or the key is blacklisted. Other errors may be returned if the signature check could not be performed.}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]keyring-link-restrictionsah ]h"]keyring link restrictionsah$]h&]uh1hhhhhhhhMJubeh}(h]+asymmetric-public-key-cryptography-key-typeah ]h"]-asymmetric / public-key cryptography key typeah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j~j{j5j2jjjjj{jxjjjjjvjsu nametypes}(j~j5jjj{jjjvuh}(j{hj2hjj8jjjxjjjjjjsju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.