You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ei...@apache.org on 2020/04/17 03:27:01 UTC
[couchdb] branch aegis_key_cache updated: Formatting: move private
functions into own section
This is an automated email from the ASF dual-hosted git repository.
eiri pushed a commit to branch aegis_key_cache
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/aegis_key_cache by this push:
new 7b78636 Formatting: move private functions into own section
7b78636 is described below
commit 7b786363d4f7574597b83a99800066260b9c7f81
Author: Eric Avdey <ei...@eiri.ca>
AuthorDate: Fri Apr 17 00:26:40 2020 -0300
Formatting: move private functions into own section
---
src/aegis/src/aegis_key_cache.erl | 109 +++++++++++++++++++-------------------
1 file changed, 54 insertions(+), 55 deletions(-)
diff --git a/src/aegis/src/aegis_key_cache.erl b/src/aegis/src/aegis_key_cache.erl
index ed2de58..bf34a12 100644
--- a/src/aegis/src/aegis_key_cache.erl
+++ b/src/aegis/src/aegis_key_cache.erl
@@ -38,10 +38,7 @@
]).
--define(ROOT_KEY, <<1:256>>).
-
-define(INIT_TIMEOUT, 60000).
-
-define(TIMEOUT, 10000).
@@ -180,6 +177,60 @@ code_change(_OldVsn, St, _Extra) ->
%% workers functions
+get_wrapped_key(#{} = Db) ->
+ process_flag(sensitive, true),
+ try
+ ?AEGIS_KEY_MANAGER:key_wrap(Db)
+ of
+ Resp ->
+ exit({key, Resp})
+ catch
+ _:Error ->
+ exit({error, Error})
+ end.
+
+
+unwrap_key(#{aegis := WrappedKey} = Db) ->
+ process_flag(sensitive, true),
+ try
+ ?AEGIS_KEY_MANAGER:key_unwrap(Db)
+ of
+ Resp ->
+ exit({key, Resp})
+ catch
+ _:Error ->
+ exit({key, {error, WrappedKey, Error}})
+ end.
+
+
+do_encrypt(DbKey, #{uuid := UUID}, Key, Value) ->
+ process_flag(sensitive, true),
+ try
+ aegis:encrypt(DbKey, UUID, Key, Value)
+ of
+ Resp ->
+ exit(Resp)
+ catch
+ _:Error ->
+ exit({error, Error})
+ end.
+
+
+do_decrypt(DbKey, #{uuid := UUID}, Key, Value) ->
+ process_flag(sensitive, true),
+ try
+ aegis:decrypt(DbKey, UUID, Key, Value)
+ of
+ Resp ->
+ exit(Resp)
+ catch
+ _:Error ->
+ exit({error, Error})
+ end.
+
+
+%% private functions
+
maybe_spawn_worker(St, From, Action, #{aegis := WrappedKey} = Db, Key, Value) ->
#{
cache := Cache,
@@ -240,58 +291,6 @@ maybe_reply(#{clients := Clients} = St, Ref, Resp) ->
end.
-get_wrapped_key(#{} = Db) ->
- process_flag(sensitive, true),
- try
- ?AEGIS_KEY_MANAGER:key_wrap(Db)
- of
- Resp ->
- exit({key, Resp})
- catch
- _:Error ->
- exit({error, Error})
- end.
-
-
-unwrap_key(#{aegis := WrappedKey} = Db) ->
- process_flag(sensitive, true),
- try
- ?AEGIS_KEY_MANAGER:key_unwrap(Db)
- of
- Resp ->
- exit({key, Resp})
- catch
- _:Error ->
- exit({key, {error, WrappedKey, Error}})
- end.
-
-
-do_encrypt(DbKey, #{uuid := UUID}, Key, Value) ->
- process_flag(sensitive, true),
- try
- aegis:encrypt(DbKey, UUID, Key, Value)
- of
- Resp ->
- exit(Resp)
- catch
- _:Error ->
- exit({error, Error})
- end.
-
-
-do_decrypt(DbKey, #{uuid := UUID}, Key, Value) ->
- process_flag(sensitive, true),
- try
- aegis:decrypt(DbKey, UUID, Key, Value)
- of
- Resp ->
- exit(Resp)
- catch
- _:Error ->
- exit({error, Error})
- end.
-
-
%% cache functions
insert(Cache, WrappedKey, DbKey) ->