@@ -2762,8 +2762,35 @@ class RelyingPartyRegistrationSpec
2762
2762
2763
2763
describe(" Other requirements:" ) {
2764
2764
it(" RSA keys must have the SIGN_ENCRYPT attribute." ) {
2765
- forAll(Gen .chooseNum(0 , Int .MaxValue .toLong * 2 + 1 )) {
2766
- attributes : Long =>
2765
+ forAll(
2766
+ Gen .chooseNum(0 , Int .MaxValue .toLong * 2 + 1 ),
2767
+ minSuccessful(5 ),
2768
+ ) { attributes : Long =>
2769
+ val testData = (RegistrationTestData .from _).tupled(
2770
+ makeCred(
2771
+ authDataAndKeypair = Some (
2772
+ TestAuthenticator
2773
+ .createAuthenticatorData(keyAlgorithm =
2774
+ COSEAlgorithmIdentifier .RS256
2775
+ )
2776
+ ),
2777
+ attributes = Some (attributes & ~ Attributes .SIGN_ENCRYPT ),
2778
+ )
2779
+ )
2780
+ val step = init(testData)
2781
+ testData.alg should be(COSEAlgorithmIdentifier .RS256 )
2782
+
2783
+ step.validations shouldBe a[Failure [_]]
2784
+ step.tryNext shouldBe a[Failure [_]]
2785
+ }
2786
+ }
2787
+
2788
+ it(""" RSA keys must have "symmetric" set to TPM_ALG_NULL""" ) {
2789
+ forAll(
2790
+ Gen .chooseNum(0 , Short .MaxValue * 2 + 1 ),
2791
+ minSuccessful(5 ),
2792
+ ) { symmetric : Int =>
2793
+ whenever(symmetric != TPM_ALG_NULL ) {
2767
2794
val testData = (RegistrationTestData .from _).tupled(
2768
2795
makeCred(
2769
2796
authDataAndKeypair = Some (
@@ -2772,71 +2799,76 @@ class RelyingPartyRegistrationSpec
2772
2799
COSEAlgorithmIdentifier .RS256
2773
2800
)
2774
2801
),
2775
- attributes =
2776
- Some (attributes & ~ Attributes .SIGN_ENCRYPT ),
2802
+ symmetric = Some (symmetric),
2777
2803
)
2778
2804
)
2779
2805
val step = init(testData)
2780
2806
testData.alg should be(COSEAlgorithmIdentifier .RS256 )
2781
2807
2782
2808
step.validations shouldBe a[Failure [_]]
2783
2809
step.tryNext shouldBe a[Failure [_]]
2810
+ }
2784
2811
}
2785
2812
}
2786
2813
2787
- it(""" RSA keys must have "symmetric" set to TPM_ALG_NULL""" ) {
2788
- forAll(Gen .chooseNum(0 , Short .MaxValue * 2 + 1 )) {
2789
- symmetric : Int =>
2790
- whenever(symmetric != TPM_ALG_NULL ) {
2791
- val testData = (RegistrationTestData .from _).tupled(
2792
- makeCred(
2793
- authDataAndKeypair = Some (
2794
- TestAuthenticator
2795
- .createAuthenticatorData(keyAlgorithm =
2796
- COSEAlgorithmIdentifier .RS256
2797
- )
2798
- ),
2799
- symmetric = Some (symmetric),
2800
- )
2814
+ it(""" RSA keys must have "scheme" set to TPM_ALG_RSASSA or TPM_ALG_NULL""" ) {
2815
+ forAll(
2816
+ Gen .chooseNum(0 , Short .MaxValue * 2 + 1 ),
2817
+ minSuccessful(5 ),
2818
+ ) { scheme : Int =>
2819
+ whenever(
2820
+ scheme != TpmRsaScheme .RSASSA && scheme != TPM_ALG_NULL
2821
+ ) {
2822
+ val testData = (RegistrationTestData .from _).tupled(
2823
+ makeCred(
2824
+ authDataAndKeypair = Some (
2825
+ TestAuthenticator
2826
+ .createAuthenticatorData(keyAlgorithm =
2827
+ COSEAlgorithmIdentifier .RS256
2828
+ )
2829
+ ),
2830
+ scheme = Some (scheme),
2801
2831
)
2802
- val step = init(testData)
2803
- testData.alg should be(COSEAlgorithmIdentifier .RS256 )
2832
+ )
2833
+ val step = init(testData)
2834
+ testData.alg should be(COSEAlgorithmIdentifier .RS256 )
2804
2835
2805
- step.validations shouldBe a[Failure [_]]
2806
- step.tryNext shouldBe a[Failure [_]]
2807
- }
2836
+ step.validations shouldBe a[Failure [_]]
2837
+ step.tryNext shouldBe a[Failure [_]]
2838
+ }
2808
2839
}
2809
2840
}
2810
2841
2811
- it(""" RSA keys must have "scheme" set to TPM_ALG_RSASSA or TPM_ALG_NULL""" ) {
2812
- forAll(Gen .chooseNum(0 , Short .MaxValue * 2 + 1 )) {
2813
- scheme : Int =>
2814
- whenever(
2815
- scheme != TpmRsaScheme .RSASSA && scheme != TPM_ALG_NULL
2816
- ) {
2817
- val testData = (RegistrationTestData .from _).tupled(
2818
- makeCred(
2819
- authDataAndKeypair = Some (
2820
- TestAuthenticator
2821
- .createAuthenticatorData(keyAlgorithm =
2822
- COSEAlgorithmIdentifier .RS256
2823
- )
2824
- ),
2825
- scheme = Some (scheme),
2826
- )
2827
- )
2828
- val step = init(testData)
2829
- testData.alg should be(COSEAlgorithmIdentifier .RS256 )
2842
+ it(" ECC keys must have the SIGN_ENCRYPT attribute." ) {
2843
+ forAll(
2844
+ Gen .chooseNum(0 , Int .MaxValue .toLong * 2 + 1 ),
2845
+ minSuccessful(5 ),
2846
+ ) { attributes : Long =>
2847
+ val testData = (RegistrationTestData .from _).tupled(
2848
+ makeCred(
2849
+ authDataAndKeypair = Some (
2850
+ TestAuthenticator
2851
+ .createAuthenticatorData(keyAlgorithm =
2852
+ COSEAlgorithmIdentifier .ES256
2853
+ )
2854
+ ),
2855
+ attributes = Some (attributes & ~ Attributes .SIGN_ENCRYPT ),
2856
+ )
2857
+ )
2858
+ val step = init(testData)
2859
+ testData.alg should be(COSEAlgorithmIdentifier .ES256 )
2830
2860
2831
- step.validations shouldBe a[Failure [_]]
2832
- step.tryNext shouldBe a[Failure [_]]
2833
- }
2861
+ step.validations shouldBe a[Failure [_]]
2862
+ step.tryNext shouldBe a[Failure [_]]
2834
2863
}
2835
2864
}
2836
2865
2837
- it(" ECC keys must have the SIGN_ENCRYPT attribute." ) {
2838
- forAll(Gen .chooseNum(0 , Int .MaxValue .toLong * 2 + 1 )) {
2839
- attributes : Long =>
2866
+ it(""" ECC keys must have "symmetric" set to TPM_ALG_NULL""" ) {
2867
+ forAll(
2868
+ Gen .chooseNum(0 , Short .MaxValue * 2 + 1 ),
2869
+ minSuccessful(5 ),
2870
+ ) { symmetric : Int =>
2871
+ whenever(symmetric != TPM_ALG_NULL ) {
2840
2872
val testData = (RegistrationTestData .from _).tupled(
2841
2873
makeCred(
2842
2874
authDataAndKeypair = Some (
@@ -2845,63 +2877,41 @@ class RelyingPartyRegistrationSpec
2845
2877
COSEAlgorithmIdentifier .ES256
2846
2878
)
2847
2879
),
2848
- attributes =
2849
- Some (attributes & ~ Attributes .SIGN_ENCRYPT ),
2880
+ symmetric = Some (symmetric),
2850
2881
)
2851
2882
)
2852
2883
val step = init(testData)
2853
2884
testData.alg should be(COSEAlgorithmIdentifier .ES256 )
2854
2885
2855
2886
step.validations shouldBe a[Failure [_]]
2856
2887
step.tryNext shouldBe a[Failure [_]]
2857
- }
2858
- }
2859
-
2860
- it(""" ECC keys must have "symmetric" set to TPM_ALG_NULL""" ) {
2861
- forAll(Gen .chooseNum(0 , Short .MaxValue * 2 + 1 )) {
2862
- symmetric : Int =>
2863
- whenever(symmetric != TPM_ALG_NULL ) {
2864
- val testData = (RegistrationTestData .from _).tupled(
2865
- makeCred(
2866
- authDataAndKeypair = Some (
2867
- TestAuthenticator
2868
- .createAuthenticatorData(keyAlgorithm =
2869
- COSEAlgorithmIdentifier .ES256
2870
- )
2871
- ),
2872
- symmetric = Some (symmetric),
2873
- )
2874
- )
2875
- val step = init(testData)
2876
- testData.alg should be(COSEAlgorithmIdentifier .ES256 )
2877
-
2878
- step.validations shouldBe a[Failure [_]]
2879
- step.tryNext shouldBe a[Failure [_]]
2880
- }
2888
+ }
2881
2889
}
2882
2890
}
2883
2891
2884
2892
it(""" ECC keys must have "scheme" set to TPM_ALG_NULL""" ) {
2885
- forAll(Gen .chooseNum(0 , Short .MaxValue * 2 + 1 )) {
2886
- scheme : Int =>
2887
- whenever(scheme != TPM_ALG_NULL ) {
2888
- val testData = (RegistrationTestData .from _).tupled(
2889
- makeCred(
2890
- authDataAndKeypair = Some (
2891
- TestAuthenticator
2892
- .createAuthenticatorData(keyAlgorithm =
2893
- COSEAlgorithmIdentifier .ES256
2894
- )
2895
- ),
2896
- scheme = Some (scheme),
2897
- )
2893
+ forAll(
2894
+ Gen .chooseNum(0 , Short .MaxValue * 2 + 1 ),
2895
+ minSuccessful(5 ),
2896
+ ) { scheme : Int =>
2897
+ whenever(scheme != TPM_ALG_NULL ) {
2898
+ val testData = (RegistrationTestData .from _).tupled(
2899
+ makeCred(
2900
+ authDataAndKeypair = Some (
2901
+ TestAuthenticator
2902
+ .createAuthenticatorData(keyAlgorithm =
2903
+ COSEAlgorithmIdentifier .ES256
2904
+ )
2905
+ ),
2906
+ scheme = Some (scheme),
2898
2907
)
2899
- val step = init(testData)
2900
- testData.alg should be(COSEAlgorithmIdentifier .ES256 )
2908
+ )
2909
+ val step = init(testData)
2910
+ testData.alg should be(COSEAlgorithmIdentifier .ES256 )
2901
2911
2902
- step.validations shouldBe a[Failure [_]]
2903
- step.tryNext shouldBe a[Failure [_]]
2904
- }
2912
+ step.validations shouldBe a[Failure [_]]
2913
+ step.tryNext shouldBe a[Failure [_]]
2914
+ }
2905
2915
}
2906
2916
}
2907
2917
}
0 commit comments