Title: Possible incompliance with RFC 8017 on RSA PKCS-v1.5 validation · Issue #2273 · bcgit/bc-java · GitHub
Open Graph Title: Possible incompliance with RFC 8017 on RSA PKCS-v1.5 validation · Issue #2273 · bcgit/bc-java
X Title: Possible incompliance with RFC 8017 on RSA PKCS-v1.5 validation · Issue #2273 · bcgit/bc-java
Description: Hello, It looks like BouncyCastle does not implement a strict validation of RSA signatures according to the requirements stated in RFC 8017. In particular, the issue concerns the DigestSignatureSpi class, that implements a fallback mecha...
Open Graph Description: Hello, It looks like BouncyCastle does not implement a strict validation of RSA signatures according to the requirements stated in RFC 8017. In particular, the issue concerns the DigestSignatureSpi...
X Description: Hello, It looks like BouncyCastle does not implement a strict validation of RSA signatures according to the requirements stated in RFC 8017. In particular, the issue concerns the DigestSignatureSpi...
Opengraph URL: https://github.com/bcgit/bc-java/issues/2273
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Possible incompliance with RFC 8017 on RSA PKCS-v1.5 validation","articleBody":"Hello,\n\nIt looks like BouncyCastle does not implement a strict validation of RSA signatures according to the requirements stated in [RFC 8017](https://www.rfc-editor.org/rfc/rfc8017).\n\nIn particular, the issue concerns the [DigestSignatureSpi](https://github.com/bcgit/bc-java/blob/r1rv83/prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/rsa/DigestSignatureSpi.java) class, that implements a fallback mechanism for, in fact, incorrectly encoded signatures, such as the ones omitting within the signed DigestInfo the NULL parameter field of the AlgorithmIdentifier attribute.\n\nPlease see the RFC 8017:\n\n>[A.2.2](https://www.rfc-editor.org/rfc/rfc8017#appendix-A.2.2). RSAES-PKCS-v1_5\n>\n> The object identifier rsaEncryption (see [Appendix A.1](https://www.rfc-editor.org/rfc/rfc8017#appendix-A.1)) identifies the\n> RSAES-PKCS1-v1_5 encryption scheme. The parameters field associated\n> with this OID in a value of type AlgorithmIdentifier SHALL have a\n> value of type NULL. This is the same as in PKCS #1 v1.5.\n\nIt also lists the definitions for every digest algorithm scheme:\n\n> digestAlgorithm identifies the hash function and SHALL be an\n> algorithm ID with an OID in the set PKCS1-v1-5DigestAlgorithms. For\n> a discussion of supported hash functions, see [Appendix B.1](https://www.rfc-editor.org/rfc/rfc8017#appendix-B.1).\n>\n> DigestAlgorithm ::= AlgorithmIdentifier {\n> {PKCS1-v1-5DigestAlgorithms}\n> }\n>\n> PKCS1-v1-5DigestAlgorithms ALGORITHM-IDENTIFIER ::= {\n> { OID id-md2 PARAMETERS NULL }|\n> { OID id-md5 PARAMETERS NULL }|\n> { OID id-sha1 PARAMETERS NULL }|\n> { OID id-sha224 PARAMETERS NULL }|\n> { OID id-sha256 PARAMETERS NULL }|\n> { OID id-sha384 PARAMETERS NULL }|\n> { OID id-sha512 PARAMETERS NULL }|\n> { OID id-sha512-224 PARAMETERS NULL }|\n> { OID id-sha512-256 PARAMETERS NULL }\n> }\n\nThus, a correctly encoded DigestInfo shall contain the NULL parameter of the AlgorithmIdentifier field, as shown in the example below:\n```\nSignatureValue : Rwu3d2y/U82j1y0ctJqXO/ODAFgoTdFlxUoiwqN91KH2LTn2aCZ8U5JNO4cAJdtMWxqpAddT0pmrNZIYIFMV0qLeVawhDVyUAYVj6/CFAfpAUjn8NV9FTGq8pGjQpidMAyODb363uG33TJebsa5useVerIhZzhgX17PvLLlbOahzzH4alDnM3+joIWU/8uytGrrgNqLF4RYOHDG2TBK3FQ8LYsZtVHdtSkFy7gw1nzD67eRciA2De5iWqxq3W4PEt3B845Kv+i9NZoGD0ss/3huFMjNU6MN4shhha6U9hcwLThNYqX0LGsUJKAmh4ZQDc7woVJA0GlC2r+inDvXb7g==\nPublic Key : MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtwrrGyhs4cyn01L1H24U5CzAX5/OY4j34JrxV2zQaHEYHl0l5JIKitzSqKOBkjKt9Mvd6BmYv69nbErqTVmJmVrVHvQrCS4MvuXqhwB/vuzzX4P3rTrZiC/6thS6OaaWOHiYj2OB/qBmTqrstHgbvdqSW4cZW4RzpW/NS7mRI5PQoXBeNM/YkNyghoT/jjHUn0+cwVUMX72DluZ+ONPWJjtTZefOszgufx82RmZ1c5m4hRpp9S5QP5hQT5i667B05uNa9U/MD1D4yw+6sg4XlIRq4t4KRaTFzHEb1ioIPsiO65r4LWwWqvyEIN35mdlS+5oJVVvEWkctIi6ki0l4swIDAQAB\nDecrypted result (b64) : MFEwDQYJYIZIAWUDBAIDBQAEQFVT9QQ6+L8Afq8FHS3WQoHbW9/65BwAzpoGJVxweSuHjf2w1+XP03I8wrWncpBHfe18egg8voonmKpXfhO0DMg=\nDecrypted result (string representation) : [[2.16.840.1.101.3.4.2.3, NULL], #5553f5043af8bf007eaf051d2dd64281db5bdffae41c00ce9a06255c70792b878dfdb0d7e5cfd3723cc2b5a77290477ded7c7a083cbe8a2798aa577e13b40cc8]\n```\n\nWhile BC intentionally (?) accepts signatures signing a wrongly encoded DigestInfo payload, omitting the NULL parameter, see an example of a such signature below:\n\n```\nSignatureValue : LWHJa8xbrrMvMtkKHBmIAH7k2kFt2N/dxqEptD5YdUDlhyo36XLmZQLBV4GTGA2PrL9i3xf/DNPbLT28CZfLoqxkJTOvTCCQ8aNzMZXh6tY8l0ukr1bqH+xboYYOojREBsEO0+QAKb7nOyj0ZiKRc52zepFvpSUFIkohCLNJJcAUIUI1R0Lv6Mipm2dq3vCCVdH80XLvTOwnnUgRjYk/QZC4PwPIgynkTk7m9RjvScqkf9+LKESopGfida/QyTtcJnAx8OaHmKZPapWrIhXAB3vfRsP9NDsxZTXk778zcsurMN2BkccMC4oFcVKt3iqlka+wg/gt8OGYJRmsi9fXvQ==\nPublic Key : MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4GdXNjzgapx6lLFUjZJS5f5rDIQE8fDr2ehYLFJSRNVOGGs/QtlxNYpsqK5K69qxPNal/gBns09vX3XCSUbKZYDXJmldNM5tmACL4O9qFCG3/u1ZCSxF8NYVu3TJ+Pwq13e51cu0MkMXdyRvr5fHE7nLuqSnrXirzTXgrQv0MaMOFtC2mplxKNGxlr9fbOMiC3rKaCoWSQwB4s9XxqdYspmJuDdH5hXlY6z/OFhlE0L6NjNDwCuOTOOucOw6Qog6PNHWtonfGS5HHYBPGX6d083dAqR8YtV0Si8qZpvrL4pMEBUpzTeQzqk0m9Vw+ZftK5jZq7qPu9Nt1v0AkdVhwQIDAQAB\nDecrypted result (b64) : ME8wCwYJYIZIAWUDBAIDBEBsbCUYxKRiYfPZARXezD4vcqGfh2fVWJgrmHGwVHv37cOMLf+AWQ+Pg5Ke30fbBXttEjH18U9VioeRxR1rFAnF\nDecrypted result (string representation) : [[2.16.840.1.101.3.4.2.3], #6c6c2518c4a46261f3d90115decc3e2f72a19f8767d558982b9871b0547bf7edc38c2dff80590f8f83929edf47db057b6d1231f5f14f558a8791c51d6b1409c5]\n```\n\nThis lenient behavior on validation causes ambiguity on validation within security critical systems relying on the BouncyCastle provider for cryptographic validation.\n\nI do not know how many incorrectly created signatures are in circulation today, but I think there shall be a way to enforce the strict validation mechanism, whether it is required by the organization policy.\n\nKR,\nAleksandr","author":{"url":"https://github.com/bsanchezb","@type":"Person","name":"bsanchezb"},"datePublished":"2026-03-20T10:36:26Z","url":"https://github.com/bcgit/bc-java/issues/2273"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1aad8f9c-176b-4a04-8cd5-fcffdccd5950 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9ABC:220F9F:1F83C0:2CBDC2:6AFBFF93 |
| html-safe-nonce | f2da6059bdc72eb52c7350c6028590bacb4013ace1e474a6b505d7b6f891950c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUJDOjIyMEY5RjoxRjgzQzA6MkNCREMyOjZBRkJGRjkzIiwidmlzaXRvcl9pZCI6IjY3NDk0NjI3ODQ0MzUyOTAwMDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 32dd2843b90500c5bf648af395aba669928dd448593b30d641037db1bed49fbc |
| hovercard-subject-tag | issue:4107116723 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bcgit/bc-java/2273/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f592263b2aa757a28d5e81cebc7202cdf3bc89377cd0a5303c9c592de4baf2f3/bcgit/bc-java/issues/2273 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f592263b2aa757a28d5e81cebc7202cdf3bc89377cd0a5303c9c592de4baf2f3/bcgit/bc-java/issues/2273 |
| og:image:alt | Hello, It looks like BouncyCastle does not implement a strict validation of RSA signatures according to the requirements stated in RFC 8017. In particular, the issue concerns the DigestSignatureSpi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bsanchezb |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| turbo-cache-control | no-preview |
| go-import | github.com/bcgit/bc-java git https://github.com/bcgit/bc-java.git |
| octolytics-dimension-user_id | 4566970 |
| octolytics-dimension-user_login | bcgit |
| octolytics-dimension-repository_id | 10416648 |
| octolytics-dimension-repository_nwo | bcgit/bc-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 10416648 |
| octolytics-dimension-repository_network_root_nwo | bcgit/bc-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width