From: dlg Date: Wed, 6 May 2015 04:00:10 +0000 (+0000) Subject: make SWAP_KEY_GET symmetrical with SWAP_KEY_PUT by having it call X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=05db9060ac29c3fd255013d038001cbe4a16f886;p=openbsd 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@ --- 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 @@ -87,6 +87,13 @@ swap_encrypt_ctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, /* NOTREACHED */ } +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) { 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 @@ -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 */