Skip to content

Commit d48b19e

Browse files
authored
Merge pull request #146 from kaidohallik/legacy-signature-algorithms
Restore legacy signature algorithms for signing
2 parents bc61573 + 1d8b905 commit d48b19e

47 files changed

Lines changed: 1288 additions & 339 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: [ "master", "v3.1" ]
66
pull_request:
7-
branches: [ "master" ]
7+
branches: [ "master", "legacy-signature-algorithms" ]
88

99
permissions:
1010
contents: read

CHANGELOG.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,34 @@
33
All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6-
## [3.1-?] - TBD
6+
## [3.2] - TBD
7+
8+
### Changes
9+
10+
- Added legacy signing algorithms (`SHA256_WITH_RSA_ENCRYPTION`, `SHA384_WITH_RSA_ENCRYPTION`, `SHA512_WITH_RSA_ENCRYPTION`) for RSASSA-PKCS#1 v1.5.
11+
- Compatible with DigiDoc4j library which does not support RSASSA-PSS.
12+
- Use `SigningSignatureAlgorithm` enum and `withSignatureAlgorithm()` on signature session builders.
13+
- Use `SigningSignatureAlgorithm.getHashAlgorithmForLegacy()` when creating `SignableData` for legacy algorithms.
14+
- Legacy algorithms do not use `signatureAlgorithmParameters` in requests or responses.
15+
- Split `SignatureAlgorithm` into `AuthenticationSignatureAlgorithm` (authentication) and `SigningSignatureAlgorithm` (signing).
16+
- Only allowed `AuthenticationSignatureAlgorithm` is `RSASSA_PSS`; default `SigningSignatureAlgorithm` is `RSASSA_PSS`.
17+
- Added `SignatureFactory` interface for creating `java.security.Signature` instance for verifying signature and added its implementations:
18+
- `RsaSsaPssSignatureFactory`
19+
- `RsaSsaPkcs1SignatureFactory`
20+
- Changed `SignatureValueValidator.validate` last parameter from `RsaSsaPssParameters` to `SignatureFactory`:
21+
- The following classes are moved from `ee.sk.smartid` to `ee.sk.smartid.signature`:
22+
- `AuthenticationSignatureAlgorithm`
23+
- `DigestInput`
24+
- `MaskGenAlgorithm`
25+
- `RsaSsaPssParameters`
26+
- `SignableData`
27+
- `SignableHash`
28+
- `SignatureValueValidator`
29+
- `SignatureValueValidatorImpl`
30+
- `SigningSignatureAlgorithm`
31+
- `TrailerField`
32+
33+
## [3.1] - 2025-10-15
734

835
### Structural changes
936

MIGRATION_GUIDE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,43 @@ Library v3.1 supports only Smart-ID v3 API.
44
All the previous v2 related code has been removed and all the code necessary for Smart-ID API v3 is under package smartid.
55
Some classes could also be used in v3 and for those classes the package did not change.
66

7+
# Migrating from library v3.1 to v3.2
8+
9+
For signing flows are restored legacy RSASSA-PKCS#1 v1.5 algorithms (`SHA256_WITH_RSA_ENCRYPTION`, `SHA384_WITH_RSA_ENCRYPTION`, `SHA512_WITH_RSA_ENCRYPTION`) which are compatible with DigiDoc4j's signing support.
10+
For that reason:
11+
- `SignatureAlgorithm` class is split into `AuthenticationSignatureAlgorithm` and `SigningSignatureAlgorithm`.
12+
- `SignatureValueValidator.validate` last parameter changed from `RsaSsaPssParameters` to `SignatureFactory`
13+
14+
Changes needed in authentication flows:
15+
- change `SignatureAlgorithm` to `AuthenticationSignatureAlgorithm`
16+
- change `SignatureValueValidator.validate` last parameter from `RsaSsaPssParameters` to `new RsaSsaPssSignatureFactory(RsaSsaPssParameters)`
17+
18+
Changes needed in signing flows:
19+
- change `SignatureAlgorithm` to `SigningSignatureAlgorithm`
20+
- suggestion for `SignatureValueValidator.validate` last parameter changes:
21+
- when using only signature algorithm RSASSA_PSS then use `new RsaSsaPssSignatureFactory(RsaSsaPssParameters)`
22+
- when using only legacy signature algorithms (`SHA256_WITH_RSA_ENCRYPTION`, `SHA384_WITH_RSA_ENCRYPTION`, `SHA512_WITH_RSA_ENCRYPTION`) then use `new RsaSsaPkcs1SignatureFactory(SigningSignatureAlgorithm)`
23+
- when both RSASSA_PSS and legacy RSA algorithms are used then possible solution is:
24+
```java
25+
SignatureFactory signatureFactory = signatureResponse.getSignatureAlgorithm().isLegacyRsa()
26+
? new RsaSsaPkcs1SignatureFactory(signatureResponse.getSignatureAlgorithm())
27+
: new RsaSsaPssSignatureFactory(signatureResponse.getRsaSsaPssParameters());
28+
```
29+
30+
The following classes are moved from `ee.sk.smartid` to `ee.sk.smartid.signature` so when used then imports need to be adjusted:
31+
- `AuthenticationSignatureAlgorithm`
32+
- `DigestInput`
33+
- `MaskGenAlgorithm`
34+
- `RsaSsaPssParameters`
35+
- `SignableData`
36+
- `SignableHash`
37+
- `SignatureValueValidator`
38+
- `SignatureValueValidatorImpl`
39+
- `SigningSignatureAlgorithm`
40+
- `TrailerField`
41+
42+
For legacy RSA with DigiDoc4j there is new chapter in README.md: [Legacy algorithms for signing with DigiDoc4j](./README.md#legacy-algorithms-for-signing-with-digidoc4j)
43+
744
# Migrating from Smart-ID v2 to Smart-ID v3 API
845

946
## Migrating authentication

0 commit comments

Comments
 (0)