mirrored from https://www.bouncycastle.org/repositories/bc-java
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added some additional work from TLS fips implementation to nonce sett…
…ing - relates to github #1950
- Loading branch information
Showing
10 changed files
with
78 additions
and
70 deletions.
There are no files selected for viewing
25 changes: 0 additions & 25 deletions
25
tls/src/main/java/org/bouncycastle/jsse/provider/GcmTls12NonceGeneratorUtil.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
tls/src/main/java/org/bouncycastle/jsse/provider/TlsNonceGeneratorFactory.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.bouncycastle.tls.crypto.impl; | ||
|
||
import org.bouncycastle.tls.TlsFatalAlert; | ||
|
||
public interface AEADNonceGenerator | ||
{ | ||
public void generateNonce(byte[] nonce) | ||
throws TlsFatalAlert; | ||
} |
8 changes: 8 additions & 0 deletions
8
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.bouncycastle.tls.crypto.impl; | ||
|
||
import org.bouncycastle.tls.crypto.TlsNonceGenerator; | ||
|
||
public interface AEADNonceGeneratorFactory | ||
{ | ||
AEADNonceGenerator create(byte[] baseNonce, int counterSizeInBits); | ||
} |
26 changes: 26 additions & 0 deletions
26
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.bouncycastle.tls.crypto.impl; | ||
|
||
import java.security.AccessController; | ||
import java.security.PrivilegedAction; | ||
|
||
final public class GcmTls12NonceGeneratorUtil | ||
{ | ||
private static AEADNonceGeneratorFactory tlsNonceGeneratorFactory = null; | ||
|
||
public static void setGcmTlsNonceGeneratorFactory(final AEADNonceGeneratorFactory factory) | ||
{ | ||
tlsNonceGeneratorFactory = factory; | ||
} | ||
|
||
public static boolean isGcmFipsNonceGeneratorFactorySet() | ||
{ | ||
return tlsNonceGeneratorFactory != null; | ||
} | ||
|
||
public static AEADNonceGenerator createGcmFipsNonceGenerator(final byte[] baseNonce, final int counterSizeInBits) | ||
{ | ||
return tlsNonceGeneratorFactory != null | ||
? tlsNonceGeneratorFactory.create(baseNonce, counterSizeInBits) | ||
: null; | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
tls/src/test/java/org/bouncycastle/tls/test/TestAEADGeneratorFactory.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.bouncycastle.tls.test; | ||
|
||
import org.bouncycastle.tls.crypto.impl.AEADNonceGenerator; | ||
import org.bouncycastle.tls.crypto.impl.AEADNonceGeneratorFactory; | ||
|
||
class TestAEADGeneratorFactory | ||
implements AEADNonceGeneratorFactory | ||
{ | ||
public static final AEADNonceGeneratorFactory INSTANCE = new TestAEADGeneratorFactory(); | ||
|
||
private TestAEADGeneratorFactory() | ||
{ | ||
// no op | ||
} | ||
|
||
@Override | ||
public AEADNonceGenerator create(final byte[] baseNonce, final int counterSizeInBits) | ||
{ | ||
return new TestAEADNonceGenerator(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
19 changes: 0 additions & 19 deletions
19
tls/src/test/java/org/bouncycastle/tls/test/TestTlsNonceGeneratorFactory.java
This file was deleted.
Oops, something went wrong.