File tree Expand file tree Collapse file tree
lib/src/main/java/com/auth0/jwtdecodejava/algorithms Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ public void verify(String[] jwtParts) throws SignatureVerificationException {
3131 s .initVerify (publicKey );
3232 s .update (content .getBytes ());
3333 byte [] signature = Base64 .decodeBase64 (jwtParts [2 ]);
34- if (isJOSESignature (signature )) {
34+ if (! isDERSignature (signature )) {
3535 signature = JOSEToDER (signature );
3636 }
3737 boolean valid = s .verify (signature );
@@ -43,9 +43,10 @@ public void verify(String[] jwtParts) throws SignatureVerificationException {
4343 }
4444 }
4545
46- private boolean isJOSESignature (byte [] signature ) {
47- //TODO: Check if the signature has JOSE format.
48- return true ;
46+ private boolean isDERSignature (byte [] signature ) {
47+ // DER Structure: http://crypto.stackexchange.com/a/1797
48+ // Should begin with 0x30 and have exactly the expected length
49+ return signature [0 ] == 0x30 && signature .length == ecNumberSize * 2 ;
4950 }
5051
5152 private byte [] JOSEToDER (byte [] joseSignature ) throws SignatureException {
You can’t perform that action at this time.
0 commit comments