Skip to content

Commit 2886c5f

Browse files
committed
Merge branch 'main' of gitlab.cryptoworkshop.com:root/bc-java
2 parents 0a1759c + d24bd76 commit 2886c5f

File tree

5 files changed

+60
-48
lines changed

5 files changed

+60
-48
lines changed

core/src/main/java/org/bouncycastle/crypto/signers/ECGOST3410Signer.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,25 @@ public class ECGOST3410Signer
2929

3030
SecureRandom random;
3131

32-
public void init(
33-
boolean forSigning,
34-
CipherParameters param)
32+
public void init(boolean forSigning, CipherParameters param)
3533
{
3634
if (forSigning)
3735
{
36+
SecureRandom providedRandom = null;
3837
if (param instanceof ParametersWithRandom)
3938
{
40-
ParametersWithRandom rParam = (ParametersWithRandom)param;
41-
42-
this.random = rParam.getRandom();
43-
this.key = (ECPrivateKeyParameters)rParam.getParameters();
44-
}
45-
else
46-
{
47-
this.random = CryptoServicesRegistrar.getSecureRandom();
48-
this.key = (ECPrivateKeyParameters)param;
39+
ParametersWithRandom withRandom = (ParametersWithRandom)param;
40+
providedRandom = withRandom.getRandom();
41+
param = withRandom.getParameters();
4942
}
43+
44+
this.key = (ECPrivateKeyParameters)param;
45+
this.random = CryptoServicesRegistrar.getSecureRandom(providedRandom);
5046
}
5147
else
5248
{
5349
this.key = (ECPublicKeyParameters)param;
50+
this.random = null;
5451
}
5552

5653
CryptoServicesRegistrar.checkConstraints(Utils.getDefaultProperties("ECGOST3410", key, forSigning));

core/src/main/java/org/bouncycastle/crypto/signers/ECNRSigner.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,27 @@ public class ECNRSigner
3737
* for verification or if we want to use the signer for message recovery.
3838
* @param param key parameters for signature generation.
3939
*/
40-
public void init(
41-
boolean forSigning,
42-
CipherParameters param)
40+
public void init(boolean forSigning, CipherParameters param)
4341
{
4442
this.forSigning = forSigning;
45-
43+
4644
if (forSigning)
4745
{
46+
SecureRandom providedRandom = null;
4847
if (param instanceof ParametersWithRandom)
4948
{
50-
ParametersWithRandom rParam = (ParametersWithRandom)param;
51-
52-
this.random = rParam.getRandom();
53-
this.key = (ECPrivateKeyParameters)rParam.getParameters();
54-
}
55-
else
56-
{
57-
this.random = CryptoServicesRegistrar.getSecureRandom();
58-
this.key = (ECPrivateKeyParameters)param;
49+
ParametersWithRandom withRandom = (ParametersWithRandom)param;
50+
providedRandom = withRandom.getRandom();
51+
param = withRandom.getParameters();
5952
}
53+
54+
this.key = (ECPrivateKeyParameters)param;
55+
this.random = CryptoServicesRegistrar.getSecureRandom(providedRandom);
6056
}
6157
else
6258
{
6359
this.key = (ECPublicKeyParameters)param;
60+
this.random = null;
6461
}
6562

6663
CryptoServicesRegistrar.checkConstraints(Utils.getDefaultProperties("ECNR", key, forSigning));

core/src/main/java/org/bouncycastle/crypto/signers/GOST3410Signer.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,25 @@ public class GOST3410Signer
2424

2525
SecureRandom random;
2626

27-
public void init(
28-
boolean forSigning,
29-
CipherParameters param)
27+
public void init(boolean forSigning, CipherParameters param)
3028
{
3129
if (forSigning)
3230
{
31+
SecureRandom providedRandom = null;
3332
if (param instanceof ParametersWithRandom)
3433
{
35-
ParametersWithRandom rParam = (ParametersWithRandom)param;
36-
37-
this.random = rParam.getRandom();
38-
this.key = (GOST3410PrivateKeyParameters)rParam.getParameters();
39-
}
40-
else
41-
{
42-
this.random = CryptoServicesRegistrar.getSecureRandom();
43-
this.key = (GOST3410PrivateKeyParameters)param;
34+
ParametersWithRandom withRandom = (ParametersWithRandom)param;
35+
providedRandom = withRandom.getRandom();
36+
param = withRandom.getParameters();
4437
}
38+
39+
this.key = (GOST3410PrivateKeyParameters)param;
40+
this.random = CryptoServicesRegistrar.getSecureRandom(providedRandom);
4541
}
4642
else
4743
{
4844
this.key = (GOST3410PublicKeyParameters)param;
45+
this.random = null;
4946
}
5047

5148
CryptoServicesRegistrar.checkConstraints(Utils.getDefaultProperties("GOST3410", key, forSigning));

core/src/main/java/org/bouncycastle/crypto/signers/ISO9796d2PSSSigner.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ public ISO9796d2PSSSigner(
125125
* @throws IllegalArgumentException if wrong parameter type or a fixed
126126
* salt is passed in which is the wrong length.
127127
*/
128-
public void init(
129-
boolean forSigning,
130-
CipherParameters param)
128+
public void init(boolean forSigning, CipherParameters param)
131129
{
132130
RSAKeyParameters kParam;
133131
int lengthOfSalt = saltLength;
@@ -137,16 +135,15 @@ public void init(
137135
ParametersWithRandom p = (ParametersWithRandom)param;
138136

139137
kParam = (RSAKeyParameters)p.getParameters();
140-
if (forSigning)
141-
{
142-
random = p.getRandom();
143-
}
138+
random = forSigning ? p.getRandom() : null;
139+
standardSalt = null;
144140
}
145141
else if (param instanceof ParametersWithSalt)
146142
{
147143
ParametersWithSalt p = (ParametersWithSalt)param;
148144

149145
kParam = (RSAKeyParameters)p.getParameters();
146+
random = null;
150147
standardSalt = p.getSalt();
151148
lengthOfSalt = standardSalt.length;
152149
if (standardSalt.length != saltLength)
@@ -157,10 +154,8 @@ else if (param instanceof ParametersWithSalt)
157154
else
158155
{
159156
kParam = (RSAKeyParameters)param;
160-
if (forSigning)
161-
{
162-
random = CryptoServicesRegistrar.getSecureRandom();
163-
}
157+
random = forSigning ? CryptoServicesRegistrar.getSecureRandom() : null;
158+
standardSalt = null;
164159
}
165160

166161
cipher.init(forSigning, kParam);

tls/src/main/java/org/bouncycastle/tls/SRTPProtectionProfile.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ public class SRTPProtectionProfile
77
*/
88
public static final int SRTP_AES128_CM_HMAC_SHA1_80 = 0x0001;
99
public static final int SRTP_AES128_CM_HMAC_SHA1_32 = 0x0002;
10+
11+
/**
12+
* Removed by draft-ietf-avt-dtls-srtp-04. IANA: Unassigned.
13+
*/
14+
public static final int DRAFT_SRTP_AES256_CM_SHA1_80 = 0x0003;
15+
/**
16+
* Removed by draft-ietf-avt-dtls-srtp-04. IANA: Unassigned.
17+
*/
18+
public static final int DRAFT_SRTP_AES256_CM_SHA1_32 = 0x0004;
19+
1020
public static final int SRTP_NULL_HMAC_SHA1_80 = 0x0005;
1121
public static final int SRTP_NULL_HMAC_SHA1_32 = 0x0006;
1222

@@ -15,4 +25,20 @@ public class SRTPProtectionProfile
1525
*/
1626
public static final int SRTP_AEAD_AES_128_GCM = 0x0007;
1727
public static final int SRTP_AEAD_AES_256_GCM = 0x0008;
28+
29+
/*
30+
* RFC 8723 10.1.
31+
*/
32+
public static final int DOUBLE_AEAD_AES_128_GCM_AEAD_AES_128_GCM = 0x0009;
33+
public static final int DOUBLE_AEAD_AES_256_GCM_AEAD_AES_256_GCM = 0x000A;
34+
35+
/*
36+
* RFC 8269 6.1.
37+
*/
38+
public static final int SRTP_ARIA_128_CTR_HMAC_SHA1_80 = 0x000B;
39+
public static final int SRTP_ARIA_128_CTR_HMAC_SHA1_32 = 0x000C;
40+
public static final int SRTP_ARIA_256_CTR_HMAC_SHA1_80 = 0x000D;
41+
public static final int SRTP_ARIA_256_CTR_HMAC_SHA1_32 = 0x000E;
42+
public static final int SRTP_AEAD_ARIA_128_GCM = 0x000F;
43+
public static final int SRTP_AEAD_ARIA_256_GCM = 0x0010;
1844
}

0 commit comments

Comments
 (0)