cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf git commit: Fixing some issues with elliptic curves in JWE
Date Wed, 14 Oct 2015 14:38:13 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 02f4a46b0 -> 06698761a


Fixing some issues with elliptic curves in JWE


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/06698761
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/06698761
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/06698761

Branch: refs/heads/3.0.x-fixes
Commit: 06698761a7ba32be4fb16dc8446885dfd2885ddf
Parents: 02f4a46
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Oct 14 15:36:24 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Oct 14 15:37:06 2015 +0100

----------------------------------------------------------------------
 .../security/jose/jwe/JweJwtCompactProducer.java  |  4 ++--
 .../apache/cxf/rs/security/jose/jwe/JweUtils.java | 10 +++++++---
 .../apache/cxf/rs/security/jose/jwk/JwkUtils.java | 18 ++++++++++--------
 3 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/06698761/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweJwtCompactProducer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweJwtCompactProducer.java
b/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweJwtCompactProducer.java
index 98702b4..5b65790 100644
--- a/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweJwtCompactProducer.java
+++ b/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweJwtCompactProducer.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 package org.apache.cxf.rs.security.jose.jwe;
-import java.security.interfaces.RSAPublicKey;
+import java.security.PublicKey;
 
 import javax.crypto.SecretKey;
 
@@ -46,7 +46,7 @@ public class JweJwtCompactProducer  {
         JweEncryptionProvider jwe = JweUtils.createJweEncryptionProvider(key, headers);
         return encryptWith(jwe);
     }
-    public String encryptWith(RSAPublicKey key) {
+    public String encryptWith(PublicKey key) {
         JweEncryptionProvider jwe = JweUtils.createJweEncryptionProvider(key, headers);
         return encryptWith(jwe);
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/06698761/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java
b/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java
index 379efaf..5032518 100644
--- a/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java
+++ b/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweUtils.java
@@ -142,11 +142,13 @@ public final class JweUtils {
         return keyEncryptionProvider;
     }
     public static KeyEncryptionProvider getPublicKeyEncryptionProvider(PublicKey key, KeyAlgorithm
algo) {
-        if (key instanceof PublicKey) {
+        if (key instanceof RSAPublicKey) {
             return new RSAKeyEncryptionAlgorithm((RSAPublicKey)key, algo);
-        } else {
+        } else if (key instanceof ECPublicKey) {
             return new EcdhAesWrapKeyEncryptionAlgorithm((ECPublicKey)key, algo);
         }
+        
+        return null;
     }
     public static KeyEncryptionProvider getSecretKeyEncryptionAlgorithm(SecretKey key, KeyAlgorithm
algo) {
         if (AlgorithmUtils.isAesKeyWrap(algo.getJwaName())) {
@@ -180,9 +182,11 @@ public final class JweUtils {
     public static KeyDecryptionProvider getPrivateKeyDecryptionProvider(PrivateKey key, KeyAlgorithm
algo) {
         if (key instanceof RSAPrivateKey) {
             return new RSAKeyDecryptionAlgorithm((RSAPrivateKey)key, algo);
-        } else {
+        } else if (key instanceof ECPrivateKey) {
             return new EcdhAesWrapKeyDecryptionAlgorithm((ECPrivateKey)key, algo);
         }
+        
+        return null;
     }
     public static KeyDecryptionProvider getSecretKeyDecryptionProvider(SecretKey key, KeyAlgorithm
algo) {
         if (AlgorithmUtils.isAesKeyWrap(algo.getJwaName())) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/06698761/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
b/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
index 44f7733..33eb305 100644
--- a/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
+++ b/rt/rs/security/jose/jose-core/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
@@ -22,6 +22,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigInteger;
 import java.net.URI;
+import java.security.PrivateKey;
+import java.security.PublicKey;
 import java.security.cert.X509Certificate;
 import java.security.interfaces.ECPrivateKey;
 import java.security.interfaces.ECPublicKey;
@@ -145,12 +147,12 @@ public final class JwkUtils {
         return jwe.encrypt(StringUtils.toBytesUTF8(writer.jwkSetToJson(jwkSet)), 
                            toJweHeaders("jwk-set+json"));
     }
-    public static String encryptJwkSet(JsonWebKeys jwkSet, RSAPublicKey key, KeyAlgorithm
keyAlgo, 
+    public static String encryptJwkSet(JsonWebKeys jwkSet, PublicKey key, KeyAlgorithm keyAlgo,

                                        ContentAlgorithm contentAlgo) {
         return JweUtils.encrypt(key, keyAlgo, contentAlgo, StringUtils.toBytesUTF8(jwkSetToJson(jwkSet)),
                                 "jwk-set+json");
     }
-    public static String signJwkSet(JsonWebKeys jwkSet, RSAPrivateKey key, SignatureAlgorithm
algo) {
+    public static String signJwkSet(JsonWebKeys jwkSet, PrivateKey key, SignatureAlgorithm
algo) {
         return JwsUtils.sign(key, algo, jwkSetToJson(jwkSet), "jwk-set+json");
     }
     public static String encryptJwkSet(JsonWebKeys jwkSet, SecretKey key, KeyAlgorithm keyAlgo,

@@ -167,11 +169,11 @@ public final class JwkUtils {
     public static JsonWebKeys decryptJwkSet(String jsonJwkSet, JweDecryptionProvider jwe,
JwkReaderWriter reader) {
         return reader.jsonToJwkSet(jwe.decrypt(jsonJwkSet).getContentText());
     }
-    public static JsonWebKeys decryptJwkSet(RSAPrivateKey key, KeyAlgorithm keyAlgo, ContentAlgorithm
ctAlgo,
+    public static JsonWebKeys decryptJwkSet(PrivateKey key, KeyAlgorithm keyAlgo, ContentAlgorithm
ctAlgo,
                                             String jsonJwkSet) {
         return readJwkSet(toString(JweUtils.decrypt(key, keyAlgo, ctAlgo, jsonJwkSet)));
     }
-    public static JsonWebKeys verifyJwkSet(RSAPublicKey key, SignatureAlgorithm keyAlgo,
String jsonJwk) {
+    public static JsonWebKeys verifyJwkSet(PublicKey key, SignatureAlgorithm keyAlgo, String
jsonJwk) {
         return readJwkSet(JwsUtils.verify(key, keyAlgo, jsonJwk));
     }
     public static JsonWebKeys decryptJwkSet(SecretKey key, KeyAlgorithm keyAlgo, ContentAlgorithm
ctAlgo, 
@@ -199,7 +201,7 @@ public final class JwkUtils {
         return jwe.encrypt(StringUtils.toBytesUTF8(writer.jwkToJson(jwkKey)), 
                            toJweHeaders("jwk+json"));
     }
-    public static String encryptJwkKey(JsonWebKey jwkKey, RSAPublicKey key, KeyAlgorithm
keyAlgo, 
+    public static String encryptJwkKey(JsonWebKey jwkKey, PublicKey key, KeyAlgorithm keyAlgo,

                                        ContentAlgorithm contentAlgo) {
         return JweUtils.encrypt(key, keyAlgo, contentAlgo, StringUtils.toBytesUTF8(jwkKeyToJson(jwkKey)),
                                 "jwk+json");
@@ -209,7 +211,7 @@ public final class JwkUtils {
         return JweUtils.encrypt(key, keyAlgo, contentAlgo, StringUtils.toBytesUTF8(jwkKeyToJson(jwkKey)),
                                 "jwk+json");
     }
-    public static String signJwkKey(JsonWebKey jwkKey, RSAPrivateKey key, SignatureAlgorithm
algo) {
+    public static String signJwkKey(JsonWebKey jwkKey, PrivateKey key, SignatureAlgorithm
algo) {
         return JwsUtils.sign(key, algo, jwkKeyToJson(jwkKey), "jwk+json");
     }
     public static JsonWebKey decryptJwkKey(String jsonJwkKey, char[] password) {
@@ -218,11 +220,11 @@ public final class JwkUtils {
     public static JsonWebKey decryptJwkKey(String jsonJwkKey, char[] password, JwkReaderWriter
reader) {
         return decryptJwkKey(jsonJwkKey, createDefaultDecryption(password), reader);
     }
-    public static JsonWebKey decryptJwkKey(RSAPrivateKey key, KeyAlgorithm keyAlgo, ContentAlgorithm
ctAlgo, 
+    public static JsonWebKey decryptJwkKey(PrivateKey key, KeyAlgorithm keyAlgo, ContentAlgorithm
ctAlgo, 
                                            String jsonJwk) {
         return readJwkKey(toString(JweUtils.decrypt(key, keyAlgo, ctAlgo, jsonJwk)));
     }
-    public static JsonWebKey verifyJwkKey(RSAPublicKey key, SignatureAlgorithm keyAlgo, String
jsonJwk) {
+    public static JsonWebKey verifyJwkKey(PublicKey key, SignatureAlgorithm keyAlgo, String
jsonJwk) {
         return readJwkKey(JwsUtils.verify(key, keyAlgo, jsonJwk));
     }
     public static JsonWebKey decryptJwkKey(SecretKey key, KeyAlgorithm keyAlgo, ContentAlgorithm
ctAlgo, 


Mime
View raw message