Skip to content

Commit b6f61c3

Browse files
committed
keys: Implement update for the big_key type
Implement the ->update op for the big_key type. Signed-off-by: David Howells <[email protected]> Acked-by: Jason A. Donenfeld <[email protected]>
1 parent 521fd61 commit b6f61c3

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

include/keys/big_key-type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ extern void big_key_revoke(struct key *key);
1818
extern void big_key_destroy(struct key *key);
1919
extern void big_key_describe(const struct key *big_key, struct seq_file *m);
2020
extern long big_key_read(const struct key *key, char *buffer, size_t buflen);
21+
extern int big_key_update(struct key *key, struct key_preparsed_payload *prep);
2122

2223
#endif /* _KEYS_BIG_KEY_TYPE_H */

security/keys/big_key.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct key_type key_type_big_key = {
4747
.destroy = big_key_destroy,
4848
.describe = big_key_describe,
4949
.read = big_key_read,
50-
/* no ->update(); don't add it without changing chacha20poly1305's nonce */
50+
.update = big_key_update,
5151
};
5252

5353
/*
@@ -191,6 +191,23 @@ void big_key_destroy(struct key *key)
191191
key->payload.data[big_key_data] = NULL;
192192
}
193193

194+
/*
195+
* Update a big key
196+
*/
197+
int big_key_update(struct key *key, struct key_preparsed_payload *prep)
198+
{
199+
int ret;
200+
201+
ret = key_payload_reserve(key, prep->datalen);
202+
if (ret < 0)
203+
return ret;
204+
205+
if (key_is_positive(key))
206+
big_key_destroy(key);
207+
208+
return generic_key_instantiate(key, prep);
209+
}
210+
194211
/*
195212
* describe the big_key key
196213
*/

0 commit comments

Comments
 (0)