Erase the tag key after use.

This commit is contained in:
akwizgran
2012-11-02 12:25:13 +00:00
parent c0c6af7a86
commit 11ea898bab
2 changed files with 22 additions and 21 deletions

View File

@@ -1,25 +1,25 @@
<project name='prototype' default='compile'> <project name='prototype' default='compile'>
<fileset id='prototype-jars' dir='../libs'> <fileset id='prototype-jars' dir='../libs'>
<include name='*.jar'/> <include name='*.jar'/>
</fileset> </fileset>
<path id='android-jar'> <path id='android-jar'>
<pathelement location='../android.jar'/> <pathelement location='../android.jar'/>
</path> </path>
<path id='prototype-classes'> <path id='prototype-classes'>
<pathelement location='../build'/> <pathelement location='../build'/>
</path> </path>
<target name='clean'> <target name='clean'>
<delete dir='../build'/> <delete dir='../build'/>
</target> </target>
<target name='compile'> <target name='compile'>
<mkdir dir='../build'/> <mkdir dir='../build'/>
<javac srcdir='net/sf/briar' destdir='../build' source='1.5' <javac srcdir='net/sf/briar' destdir='../build' source='1.5'
includeantruntime='false' debug='off'> includeantruntime='false' debug='off'>
<classpath> <classpath>
<fileset refid='prototype-jars'/> <fileset refid='prototype-jars'/>
<path refid='android-jar'/> <path refid='android-jar'/>
<path refid='prototype-classes'/> <path refid='prototype-classes'/>
</classpath> </classpath>
</javac> </javac>
</target> </target>
</project> </project>

View File

@@ -55,7 +55,7 @@ class TransportConnectionRecogniser {
for(long connection1 : window.setSeen(connection)) { for(long connection1 : window.setSeen(connection)) {
byte[] tag1 = new byte[TAG_LENGTH]; byte[] tag1 = new byte[TAG_LENGTH];
crypto.encodeTag(tag1, cipher, key, connection1); crypto.encodeTag(tag1, cipher, key, connection1);
if(connection1 <= connection) { if(connection1 < connection) {
TagContext old = tagMap.remove(new Bytes(tag1)); TagContext old = tagMap.remove(new Bytes(tag1));
assert old != null; assert old != null;
ByteUtils.erase(old.context.getSecret()); ByteUtils.erase(old.context.getSecret());
@@ -95,6 +95,7 @@ class TransportConnectionRecogniser {
TagContext old = tagMap.put(new Bytes(tag), tctx); TagContext old = tagMap.put(new Bytes(tag), tctx);
assert old == null; assert old == null;
} }
key.erase();
// Create a removal context to remove the window later // Create a removal context to remove the window later
RemovalContext rctx = new RemovalContext(window, secret, alice); RemovalContext rctx = new RemovalContext(window, secret, alice);
removalMap.put(new RemovalKey(contactId, period), rctx); removalMap.put(new RemovalKey(contactId, period), rctx);