diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-05-06 04:00:11 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-05-06 04:00:11 +0000 |
commit | 56bd73cead74f0b3a21c0ef4ae8f8647d83e04ab (patch) | |
tree | 8a03dd4e2ebe69f52d98c50fccb48fc8ccbf21ea | |
parent | 89622a4d2764079009502ff9b5ecd2d24f0bf0e3 (diff) |
make SWAP_KEY_GET symmetrical with SWAP_KEY_PUT by having it call
a function in uvm_swap_encrypt.c instead of doing stuff inline.
lets me remove an extern from the header too.
ok kettenis@
-rw-r--r-- | sys/uvm/uvm_swap_encrypt.c | 9 | ||||
-rw-r--r-- | sys/uvm/uvm_swap_encrypt.h | 9 |
2 files changed, 11 insertions, 7 deletions
diff --git a/sys/uvm/uvm_swap_encrypt.c b/sys/uvm/uvm_swap_encrypt.c index ae764547324..71406f13ee3 100644 --- a/sys/uvm/uvm_swap_encrypt.c +++ b/sys/uvm/uvm_swap_encrypt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_swap_encrypt.c,v 1.21 2015/05/04 10:21:15 dlg Exp $ */ +/* $OpenBSD: uvm_swap_encrypt.c,v 1.22 2015/05/06 04:00:10 dlg Exp $ */ /* * Copyright 1999 Niels Provos <provos@citi.umich.edu> @@ -88,6 +88,13 @@ swap_encrypt_ctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, } void +swap_key_create(struct swap_key *key) +{ + arc4random_buf(key->key, sizeof(key->key)); + uvm_swpkeyscreated++; +} + +void swap_key_delete(struct swap_key *key) { /* Make sure that this key gets removed if we just used it */ diff --git a/sys/uvm/uvm_swap_encrypt.h b/sys/uvm/uvm_swap_encrypt.h index 3545ae02be5..e883f6b758b 100644 --- a/sys/uvm/uvm_swap_encrypt.h +++ b/sys/uvm/uvm_swap_encrypt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_swap_encrypt.h,v 1.9 2009/03/23 22:10:04 oga Exp $ */ +/* $OpenBSD: uvm_swap_encrypt.h,v 1.10 2015/05/06 04:00:10 dlg Exp $ */ /* * Copyright 1999 Niels Provos <provos@citi.umich.edu> @@ -61,13 +61,9 @@ void swap_decrypt(struct swap_key *,caddr_t, caddr_t, u_int64_t, size_t); void swap_key_cleanup(struct swap_key *); void swap_key_prepare(struct swap_key *, int); -extern u_int uvm_swpkeyscreated; - #define SWAP_KEY_GET(s,x) do { \ if ((x)->refcount == 0) { \ - arc4random_buf((x)->key,\ - sizeof((x)->key)); \ - uvm_swpkeyscreated++; \ + swap_key_create(x); \ } \ (x)->refcount++; \ } while(0); @@ -79,6 +75,7 @@ extern u_int uvm_swpkeyscreated; } \ } while(0); +void swap_key_create(struct swap_key *); void swap_key_delete(struct swap_key *); extern int uvm_doswapencrypt; /* swapencrypt enabled/disabled */ |