You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+21
Original file line number
Diff line number
Diff line change
@@ -681,6 +681,8 @@ func main() {
681
681
}
682
682
```
683
683
684
+
Two phase validation can be used for implementing additional things like strict `alg` or `enc` validation, see [Customizing library for security](#customizing-library-for-security) for more information.
685
+
684
686
### Working with binary payload
685
687
In addition to work with string payloads (typical use-case) `jose2go` supports
686
688
encoding and decoding of raw binary data. `jose.DecodeBytes`, `jose.SignBytes`
@@ -940,6 +942,25 @@ One can use following methods to deregister any signing, encryption, key managem
940
942
941
943
All of them expecting alg name matching `jose` constants and returns implementation that have been deregistered.
942
944
945
+
### Strict validation
946
+
Sometimes it is desirable to verify that `alg` or `enc` values are matching expected before attempting to decode actual payload.
947
+
`jose2go` provides helper matchers to be used within [Two-phase validation](#two-phase-validation) precheck:
948
+
949
+
-`jose.Alg(key, alg)` - to match alg header
950
+
-`jose.Enc(key, alg)` - to match alg and enc headers
As it quite easy to abuse PBES2 family of algorithms via forging header with extra large p2c values, jose-jwt library introduced iteration count limits in v1.6 to reduce runtime exposure.
0 commit comments