2012-09-22 06:24:55 +08:00
|
|
|
/* Asymmetric public-key algorithm definitions
|
|
|
|
*
|
|
|
|
* See Documentation/crypto/asymmetric-keys.txt
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public Licence
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the Licence, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_PUBLIC_KEY_H
|
|
|
|
#define _LINUX_PUBLIC_KEY_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cryptographic data for the public-key subtype of the asymmetric key type.
|
|
|
|
*
|
|
|
|
* Note that this may include private part of the key as well as the public
|
|
|
|
* part.
|
|
|
|
*/
|
|
|
|
struct public_key {
|
2016-02-03 02:08:53 +08:00
|
|
|
void *key;
|
|
|
|
u32 keylen;
|
2016-03-04 05:49:27 +08:00
|
|
|
const char *id_type;
|
|
|
|
const char *pkey_algo;
|
2012-09-22 06:24:55 +08:00
|
|
|
};
|
|
|
|
|
2016-04-06 23:13:33 +08:00
|
|
|
extern void public_key_free(struct public_key *key);
|
2012-09-22 06:24:55 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Public key cryptography signature data
|
|
|
|
*/
|
|
|
|
struct public_key_signature {
|
2016-04-06 23:13:33 +08:00
|
|
|
struct asymmetric_key_id *auth_ids[2];
|
2016-02-03 02:08:53 +08:00
|
|
|
u8 *s; /* Signature */
|
|
|
|
u32 s_size; /* Number of bytes in signature */
|
2012-09-22 06:24:55 +08:00
|
|
|
u8 *digest;
|
2016-02-03 02:09:03 +08:00
|
|
|
u8 digest_size; /* Number of bytes in digest */
|
2016-03-04 05:49:27 +08:00
|
|
|
const char *pkey_algo;
|
|
|
|
const char *hash_algo;
|
2012-09-22 06:24:55 +08:00
|
|
|
};
|
|
|
|
|
2016-04-06 23:13:33 +08:00
|
|
|
extern void public_key_signature_free(struct public_key_signature *sig);
|
|
|
|
|
2016-02-03 02:08:53 +08:00
|
|
|
extern struct asymmetric_key_subtype public_key_subtype;
|
2016-04-06 23:13:33 +08:00
|
|
|
|
2012-09-22 06:25:04 +08:00
|
|
|
struct key;
|
KEYS: Move the point of trust determination to __key_link()
Move the point at which a key is determined to be trustworthy to
__key_link() so that we use the contents of the keyring being linked in to
to determine whether the key being linked in is trusted or not.
What is 'trusted' then becomes a matter of what's in the keyring.
Currently, the test is done when the key is parsed, but given that at that
point we can only sensibly refer to the contents of the system trusted
keyring, we can only use that as the basis for working out the
trustworthiness of a new key.
With this change, a trusted keyring is a set of keys that once the
trusted-only flag is set cannot be added to except by verification through
one of the contained keys.
Further, adding a key into a trusted keyring, whilst it might grant
trustworthiness in the context of that keyring, does not automatically
grant trustworthiness in the context of a second keyring to which it could
be secondarily linked.
To accomplish this, the authentication data associated with the key source
must now be retained. For an X.509 cert, this means the contents of the
AuthorityKeyIdentifier and the signature data.
If system keyrings are disabled then restrict_link_by_builtin_trusted()
resolves to restrict_link_reject(). The integrity digital signature code
still works correctly with this as it was previously using
KEY_FLAG_TRUSTED_ONLY, which doesn't permit anything to be added if there
is no system keyring against which trust can be determined.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-04-06 23:14:26 +08:00
|
|
|
struct key_type;
|
|
|
|
union key_payload;
|
|
|
|
|
2016-08-31 02:33:13 +08:00
|
|
|
extern int restrict_link_by_signature(struct key *dest_keyring,
|
KEYS: Move the point of trust determination to __key_link()
Move the point at which a key is determined to be trustworthy to
__key_link() so that we use the contents of the keyring being linked in to
to determine whether the key being linked in is trusted or not.
What is 'trusted' then becomes a matter of what's in the keyring.
Currently, the test is done when the key is parsed, but given that at that
point we can only sensibly refer to the contents of the system trusted
keyring, we can only use that as the basis for working out the
trustworthiness of a new key.
With this change, a trusted keyring is a set of keys that once the
trusted-only flag is set cannot be added to except by verification through
one of the contained keys.
Further, adding a key into a trusted keyring, whilst it might grant
trustworthiness in the context of that keyring, does not automatically
grant trustworthiness in the context of a second keyring to which it could
be secondarily linked.
To accomplish this, the authentication data associated with the key source
must now be retained. For an X.509 cert, this means the contents of the
AuthorityKeyIdentifier and the signature data.
If system keyrings are disabled then restrict_link_by_builtin_trusted()
resolves to restrict_link_reject(). The integrity digital signature code
still works correctly with this as it was previously using
KEY_FLAG_TRUSTED_ONLY, which doesn't permit anything to be added if there
is no system keyring against which trust can be determined.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-04-06 23:14:26 +08:00
|
|
|
const struct key_type *type,
|
2016-08-31 02:33:13 +08:00
|
|
|
const union key_payload *payload,
|
|
|
|
struct key *trust_keyring);
|
KEYS: Move the point of trust determination to __key_link()
Move the point at which a key is determined to be trustworthy to
__key_link() so that we use the contents of the keyring being linked in to
to determine whether the key being linked in is trusted or not.
What is 'trusted' then becomes a matter of what's in the keyring.
Currently, the test is done when the key is parsed, but given that at that
point we can only sensibly refer to the contents of the system trusted
keyring, we can only use that as the basis for working out the
trustworthiness of a new key.
With this change, a trusted keyring is a set of keys that once the
trusted-only flag is set cannot be added to except by verification through
one of the contained keys.
Further, adding a key into a trusted keyring, whilst it might grant
trustworthiness in the context of that keyring, does not automatically
grant trustworthiness in the context of a second keyring to which it could
be secondarily linked.
To accomplish this, the authentication data associated with the key source
must now be retained. For an X.509 cert, this means the contents of the
AuthorityKeyIdentifier and the signature data.
If system keyrings are disabled then restrict_link_by_builtin_trusted()
resolves to restrict_link_reject(). The integrity digital signature code
still works correctly with this as it was previously using
KEY_FLAG_TRUSTED_ONLY, which doesn't permit anything to be added if there
is no system keyring against which trust can be determined.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-04-06 23:14:26 +08:00
|
|
|
|
2012-09-22 06:25:04 +08:00
|
|
|
extern int verify_signature(const struct key *key,
|
|
|
|
const struct public_key_signature *sig);
|
|
|
|
|
2016-02-03 02:08:53 +08:00
|
|
|
int public_key_verify_signature(const struct public_key *pkey,
|
|
|
|
const struct public_key_signature *sig);
|
|
|
|
|
2012-09-22 06:24:55 +08:00
|
|
|
#endif /* _LINUX_PUBLIC_KEY_H */
|