mirrored from https://www.bouncycastle.org/repositories/bc-java
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup TLS 1.2 GCM nonce generator stuff
- Loading branch information
1 parent
94607c5
commit a912b69
Showing
6 changed files
with
33 additions
and
45 deletions.
There are no files selected for viewing
5 changes: 2 additions & 3 deletions
5
tls/src/main/java/org/bouncycastle/tls/crypto/impl/AEADNonceGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
package org.bouncycastle.tls.crypto.impl; | ||
|
||
import org.bouncycastle.tls.TlsFatalAlert; | ||
import java.io.IOException; | ||
|
||
public interface AEADNonceGenerator | ||
{ | ||
public void generateNonce(byte[] nonce) | ||
throws TlsFatalAlert; | ||
public void generateNonce(byte[] nonce) throws IOException; | ||
} |
2 changes: 0 additions & 2 deletions
2
tls/src/main/java/org/bouncycastle/tls/crypto/impl/AEADNonceGeneratorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 7 additions & 12 deletions
19
tls/src/main/java/org/bouncycastle/tls/crypto/impl/GcmTls12NonceGeneratorUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
package org.bouncycastle.tls.crypto.impl; | ||
|
||
import java.security.AccessController; | ||
import java.security.PrivilegedAction; | ||
|
||
final public class GcmTls12NonceGeneratorUtil | ||
public final class GcmTls12NonceGeneratorUtil | ||
{ | ||
private static AEADNonceGeneratorFactory tlsNonceGeneratorFactory = null; | ||
private static volatile AEADNonceGeneratorFactory globalFactory = null; | ||
|
||
public static void setGcmTlsNonceGeneratorFactory(final AEADNonceGeneratorFactory factory) | ||
public static void setGcmTlsNonceGeneratorFactory(AEADNonceGeneratorFactory factory) | ||
{ | ||
tlsNonceGeneratorFactory = factory; | ||
globalFactory = factory; | ||
} | ||
|
||
public static boolean isGcmFipsNonceGeneratorFactorySet() | ||
{ | ||
return tlsNonceGeneratorFactory != null; | ||
return globalFactory != null; | ||
} | ||
|
||
public static AEADNonceGenerator createGcmFipsNonceGenerator(final byte[] baseNonce, final int counterSizeInBits) | ||
public static AEADNonceGenerator createGcmFipsNonceGenerator(byte[] baseNonce, int counterSizeInBits) | ||
{ | ||
return tlsNonceGeneratorFactory != null | ||
? tlsNonceGeneratorFactory.create(baseNonce, counterSizeInBits) | ||
: null; | ||
return globalFactory == null ? null : globalFactory.create(baseNonce, counterSizeInBits); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters