Skip to content

Commit

Permalink
Add key id to sym keys
Browse files Browse the repository at this point in the history
  • Loading branch information
fireduck64 committed Aug 20, 2020
1 parent f39f6c1 commit f1bc54c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/src/CipherUtil.java
Expand Up @@ -95,6 +95,14 @@ public static SymmetricKey generageSymmetricKey()
byte[] key_data = new byte[SYM_BLOCK_SIZE_0];
rnd.nextBytes(key_data);
key.setKey( ByteString.copyFrom(key_data) );

// Probably overly paranoid, but as the key_id will be shared
// using a new low security rnd to not give away any state information
// from the secure rnd
Random rnd_low = new Random();
byte[] key_id_data = new byte[8];
rnd_low.nextBytes(key_id_data);
key.setKeyId( HexUtil.getHexString( key_id_data ) );
return key.build();

}
Expand Down
1 change: 1 addition & 0 deletions protolib/util.proto
Expand Up @@ -72,5 +72,6 @@ message SymmetricKey {
// See snowblossom.lib.CipherUtil
int32 algo_set = 1;
bytes key = 2;
string key_id = 3; // Randomly generated key id
}

0 comments on commit f1bc54c

Please sign in to comment.