Skip to content

Commit ab69ecc

Browse files
authored
Allow null values in signing algorithm parameters. (#70)
Added signAlgoParams parameter in signHash and signDoc methods.
1 parent aa84549 commit ab69ecc

8 files changed

Lines changed: 41 additions & 6 deletions

File tree

api/eudi-lib-jvm-rqes-csc-kt.api

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,8 +2081,13 @@ public final class eu/europa/ec/eudi/rqes/ServiceAuthorizationRequestPrepared$Co
20812081
}
20822082

20832083
public abstract interface class eu/europa/ec/eudi/rqes/SignDoc {
2084-
public abstract fun signDoc-5KfB3zM (Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL2;Ljava/util/List;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2085-
public abstract fun signDoc-YTnCqUo (Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL1;Ljava/util/List;Leu/europa/ec/eudi/rqes/DocumentDigestList;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2084+
public abstract fun signDoc-2IQxUvg (Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL2;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2085+
public abstract fun signDoc-yw8GWXw (Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL1;Ljava/util/List;Leu/europa/ec/eudi/rqes/DocumentDigestList;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2086+
}
2087+
2088+
public final class eu/europa/ec/eudi/rqes/SignDoc$DefaultImpls {
2089+
public static synthetic fun signDoc-2IQxUvg$default (Leu/europa/ec/eudi/rqes/SignDoc;Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL2;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
2090+
public static synthetic fun signDoc-yw8GWXw$default (Leu/europa/ec/eudi/rqes/SignDoc;Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL1;Ljava/util/List;Leu/europa/ec/eudi/rqes/DocumentDigestList;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
20862091
}
20872092

20882093
public final class eu/europa/ec/eudi/rqes/SignDocResponse {
@@ -2102,8 +2107,13 @@ public final class eu/europa/ec/eudi/rqes/SignDocResponse {
21022107
}
21032108

21042109
public abstract interface class eu/europa/ec/eudi/rqes/SignHash {
2105-
public abstract fun signHash-5KfB3zM (Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL1;Leu/europa/ec/eudi/rqes/DocumentDigestList;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2106-
public abstract fun signHash-PAqFIkU (Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL2;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2110+
public abstract fun signHash-2IQxUvg (Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL1;Leu/europa/ec/eudi/rqes/DocumentDigestList;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2111+
public abstract fun signHash-cqdPT90 (Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL2;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
2112+
}
2113+
2114+
public final class eu/europa/ec/eudi/rqes/SignHash$DefaultImpls {
2115+
public static synthetic fun signHash-2IQxUvg$default (Leu/europa/ec/eudi/rqes/SignHash;Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL1;Leu/europa/ec/eudi/rqes/DocumentDigestList;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
2116+
public static synthetic fun signHash-cqdPT90$default (Leu/europa/ec/eudi/rqes/SignHash;Leu/europa/ec/eudi/rqes/CredentialAuthorized$SCAL2;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
21072117
}
21082118

21092119
public final class eu/europa/ec/eudi/rqes/Signature {

src/main/kotlin/eu/europa/ec/eudi/rqes/SignDoc.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ interface SignDoc {
3333
documents: List<DocumentToSign>,
3434
documentDigestList: DocumentDigestList,
3535
signingAlgorithmOID: SigningAlgorithmOID,
36+
signingAlgorithmParams: String? = null,
3637
): Result<SignDocResponse>
3738

3839
suspend fun CredentialAuthorized.SCAL2.signDoc(
3940
documents: List<DocumentToSign>,
4041
signingAlgorithmOID: SigningAlgorithmOID,
42+
signingAlgorithmParams: String? = null,
4143
): Result<SignDocResponse>
4244
}

src/main/kotlin/eu/europa/ec/eudi/rqes/SignHash.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,23 @@ interface SignHash {
2121
* Signs the hash of the given document digest list using the given signing algorithm OID.
2222
* @param documentDigestList the document digests to sign
2323
* @param signingAlgorithmOID the signing algorithm OID to use
24+
* @param signingAlgorithmParams the Base64-encoded DER-encoded ASN.1 signature parameters, if required by the signing algorithm
2425
* @return the list of signatures
2526
*/
2627
suspend fun CredentialAuthorized.SCAL1.signHash(
2728
documentDigestList: DocumentDigestList,
2829
signingAlgorithmOID: SigningAlgorithmOID,
30+
signingAlgorithmParams: String? = null,
2931
): Result<SignaturesList>
3032

3133
/**
3234
* Signs the hash of the given document digest list using the given signing algorithm OID.
3335
* @param signingAlgorithmOID the signing algorithm OID to use
36+
* @param signingAlgorithmParams the Base64-encoded DER-encoded ASN.1 signature parameters, if required by the signing algorithm
3437
* @return the list of signatures
3538
*/
36-
suspend fun CredentialAuthorized.SCAL2.signHash(signingAlgorithmOID: SigningAlgorithmOID): Result<SignaturesList>
39+
suspend fun CredentialAuthorized.SCAL2.signHash(
40+
signingAlgorithmOID: SigningAlgorithmOID,
41+
signingAlgorithmParams: String? = null,
42+
): Result<SignaturesList>
3743
}

src/main/kotlin/eu/europa/ec/eudi/rqes/internal/SignDocImpl.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,27 @@ internal class SignDocImpl(
2626
documents: List<DocumentToSign>,
2727
documentDigestList: DocumentDigestList,
2828
signingAlgorithmOID: SigningAlgorithmOID,
29+
signingAlgorithmParams: String?,
2930
): Result<SignDocResponse> = signDocument(
3031
credentialID,
3132
documents,
3233
documentDigestList,
3334
signingAlgorithmOID,
35+
signingAlgorithmParams,
3436
tokens.accessToken,
3537
credentialCertificate,
3638
)
3739

3840
override suspend fun CredentialAuthorized.SCAL2.signDoc(
3941
documents: List<DocumentToSign>,
4042
signingAlgorithmOID: SigningAlgorithmOID,
43+
signingAlgorithmParams: String?,
4144
): Result<SignDocResponse> = signDocument(
4245
credentialID,
4346
documents,
4447
documentDigestList,
4548
signingAlgorithmOID,
49+
signingAlgorithmParams,
4650
tokens.accessToken,
4751
credentialCertificate,
4852
)
@@ -53,6 +57,7 @@ internal class SignDocImpl(
5357
documents: List<DocumentToSign>,
5458
documentDigestList: DocumentDigestList,
5559
signingAlgorithmOID: SigningAlgorithmOID,
60+
signingAlgorithmParams: String?,
5661
accessToken: AccessToken,
5762
credentialCertificate: CredentialCertificate,
5863
): Result<SignDocResponse> = runCatching {

src/main/kotlin/eu/europa/ec/eudi/rqes/internal/SignHashImpl.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,28 @@ internal class SignHashImpl(private val signHashEndpointClient: SignHashEndpoint
2323
override suspend fun CredentialAuthorized.SCAL1.signHash(
2424
documentDigestList: DocumentDigestList,
2525
signingAlgorithmOID: SigningAlgorithmOID,
26+
signingAlgorithmParams: String?,
2627
): Result<SignaturesList> = runCatching {
2728
signHashEndpointClient.signHashes(
2829
credentialID,
2930
documentDigestList.documentDigests.map { it.hash.value },
3031
documentDigestList.hashAlgorithmOID,
3132
signingAlgorithmOID,
33+
signingAlgorithmParams,
3234
tokens.accessToken,
3335
)
3436
}
3537

3638
override suspend fun CredentialAuthorized.SCAL2.signHash(
3739
signingAlgorithmOID: SigningAlgorithmOID,
40+
signingAlgorithmParams: String?,
3841
): Result<SignaturesList> = runCatching {
3942
signHashEndpointClient.signHashes(
4043
credentialID,
4144
documentDigestList.documentDigests.map(DocumentDigest::hash).map { it.value },
4245
documentDigestList.hashAlgorithmOID,
4346
signingAlgorithmOID,
47+
signingAlgorithmParams,
4448
tokens.accessToken,
4549
)
4650
}

src/main/kotlin/eu/europa/ec/eudi/rqes/internal/http/RSSPMetadataJsonParser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private data class RSSPMetadataTO(
5252
@Serializable
5353
private data class SignAlgorithms(
5454
@SerialName("algos") @Required val algos: List<String>,
55-
@SerialName("algoParams") val algoParams: List<String>? = null,
55+
@SerialName("algoParams") val algoParams: List<String?>? = null,
5656
)
5757

5858
@Serializable

src/main/kotlin/eu/europa/ec/eudi/rqes/internal/http/SignHashEndpointClient.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ internal data class SignHashRequestTO(
2929
@SerialName("hashes") val hashes: List<String>,
3030
@SerialName("hashAlgorithmOID") val hashAlgorithmOID: String,
3131
@SerialName("signAlgo") val signAlgorithmOID: String,
32+
@SerialName("signAlgoParams") val signAlgorithmParams: String?,
3233
@SerialName("operationMode") val operationMode: String = "S",
3334
)
3435

@@ -63,6 +64,7 @@ internal class SignHashEndpointClient(
6364
hashes: List<String>,
6465
hashAlgorithmOID: HashAlgorithmOID,
6566
signAlgorithmOID: SigningAlgorithmOID,
67+
signingAlgorithmParams: String?,
6668
token: AccessToken,
6769
): SignaturesList =
6870
ktorHttpClientFactory().use { client ->
@@ -75,6 +77,7 @@ internal class SignHashEndpointClient(
7577
hashes,
7678
hashAlgorithmOID.value,
7779
signAlgorithmOID.value,
80+
signingAlgorithmParams,
7881
),
7982
)
8083
}

src/test/resources/eu/europa/ec/eudi/rqes/internal/rssp_metadata_valid.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
"1.2.840.10045.4.3.2",
3434
"1.2.840.113549.1.1.1",
3535
"1.2.840.113549.1.1.10"
36+
],
37+
"algoParams": [
38+
null,
39+
null,
40+
"MDGgCzAJBgUrDgMCGgUAoRgwFgYJKoZIhvcNAQEIMAkGBSsOAwIaBQCiAwIBFKMDAgEB"
3641
]
3742
},
3843
"signature_formats": {

0 commit comments

Comments
 (0)