Skip to content

Commit 0fbdb60

Browse files
committed
Add SecretKeyUtil to help with key cleanup
1 parent b4f167c commit 0fbdb60

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.bouncycastle.tls.crypto.impl.jcajce;
2+
3+
import javax.crypto.SecretKey;
4+
import javax.security.auth.Destroyable;
5+
6+
abstract class SecretKeyUtil
7+
{
8+
static void destroy(SecretKey secretKey)
9+
{
10+
if (secretKey instanceof Destroyable)
11+
{
12+
try
13+
{
14+
((Destroyable)secretKey).destroy();
15+
}
16+
catch (Exception e)
17+
{
18+
}
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.bouncycastle.tls.crypto.impl.jcajce;
2+
3+
import javax.crypto.SecretKey;
4+
import javax.security.auth.Destroyable;
5+
6+
abstract class SecretKeyUtil
7+
{
8+
static void destroy(SecretKey secretKey)
9+
{
10+
if (secretKey != null)
11+
{
12+
try
13+
{
14+
((Destroyable)secretKey).destroy();
15+
}
16+
catch (Exception e)
17+
{
18+
}
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)