mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
keys: add new key-type encrypted
Define a new kernel key-type called 'encrypted'. Encrypted keys are kernel generated random numbers, which are encrypted/decrypted with a 'trusted' symmetric key. Encrypted keys are created/encrypted/decrypted in the kernel. Userspace only ever sees/stores encrypted blobs. Changelog: - bug fix: replaced master-key rcu based locking with semaphore (reported by David Howells) - Removed memset of crypto_shash_digest() digest output - Replaced verification of 'key-type:key-desc' using strcspn(), with one based on string constants. - Moved documentation to Documentation/keys-trusted-encrypted.txt - Replace hash with shash (based on comments by David Howells) - Make lengths/counts size_t where possible (based on comments by David Howells) Could not convert most lengths, as crypto expects 'unsigned int' (size_t: on 32 bit is defined as unsigned int, but on 64 bit is unsigned long) - Add 'const' where possible (based on comments by David Howells) - allocate derived_buf dynamically to support arbitrary length master key (fixed by Roberto Sassu) - wait until late_initcall for crypto libraries to be registered - cleanup security/Kconfig - Add missing 'update' keyword (reported/fixed by Roberto Sassu) - Free epayload on failure to create key (reported/fixed by Roberto Sassu) - Increase the data size limit (requested by Roberto Sassu) - Crypto return codes are always 0 on success and negative on failure, remove unnecessary tests. - Replaced kzalloc() with kmalloc() Signed-off-by: Mimi Zohar <zohar@us.ibm.com> Signed-off-by: David Safford <safford@watson.ibm.com> Reviewed-by: Roberto Sassu <roberto.sassu@polito.it> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
parent
d00a1c72f7
commit
7e70cb4978
5 changed files with 1009 additions and 0 deletions
29
include/keys/encrypted-type.h
Normal file
29
include/keys/encrypted-type.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 2010 IBM Corporation
|
||||
* Author: Mimi Zohar <zohar@us.ibm.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 2 of the License.
|
||||
*/
|
||||
|
||||
#ifndef _KEYS_ENCRYPTED_TYPE_H
|
||||
#define _KEYS_ENCRYPTED_TYPE_H
|
||||
|
||||
#include <linux/key.h>
|
||||
#include <linux/rcupdate.h>
|
||||
|
||||
struct encrypted_key_payload {
|
||||
struct rcu_head rcu;
|
||||
char *master_desc; /* datablob: master key name */
|
||||
char *datalen; /* datablob: decrypted key length */
|
||||
u8 *iv; /* datablob: iv */
|
||||
u8 *encrypted_data; /* datablob: encrypted data */
|
||||
unsigned short datablob_len; /* length of datablob */
|
||||
unsigned short decrypted_datalen; /* decrypted data length */
|
||||
u8 decrypted_data[0]; /* decrypted data + datablob + hmac */
|
||||
};
|
||||
|
||||
extern struct key_type key_type_encrypted;
|
||||
|
||||
#endif /* _KEYS_ENCRYPTED_TYPE_H */
|
Loading…
Add table
Add a link
Reference in a new issue