[java-oidc-common] branch main updated: JCOMOIDC-67 - Improve support for RSA* and ECDH-ES* JWE algorithms

Henri Mikkonen henri.mikkonen at iki.fi
Mon Mar 13 16:14:14 UTC 2023


This is an automated email from the git hooks/post-receive script.

hjmikkon pushed a commit to branch main
in repository java-oidc-common.

View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=d15de90a2abd2dea99909ab0812307634ee8e2d8

The following commit(s) were added to refs/heads/main by this push:
     new d15de90  JCOMOIDC-67 - Improve support for RSA* and ECDH-ES* JWE algorithms
d15de90 is described below

commit d15de90a2abd2dea99909ab0812307634ee8e2d8
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Mon Mar 13 18:12:09 2023 +0200

    JCOMOIDC-67 - Improve support for RSA* and ECDH-ES* JWE algorithms
    
    https://shibboleth.atlassian.net/browse/JCOMOIDC-67
    
    Added the following algorithm descriptors:
    
    - RSA-OAEP-384
    - RSA-OAEP-512
    - ECDH-ES+A128KW
    - ECDH-ES+A192KW
    - ECDH-ES+A256KW
---
 .../descriptors/KeyAgreementECDHESA128KW.java      | 52 +++++++++++++++
 .../descriptors/KeyAgreementECDHESA192KW.java      | 52 +++++++++++++++
 .../descriptors/KeyAgreementECDHESA256KW.java      | 52 +++++++++++++++
 .../descriptors/KeyTransportRSAOAEP384.java        | 76 ++++++++++++++++++++++
 .../descriptors/KeyTransportRSAOAEP512.java        | 76 ++++++++++++++++++++++
 .../oidc/jwa/support/JCAConstantExtension.java     |  8 ++-
 .../oidc/jwa/support/KeyManagementConstants.java   |  6 ++
 ...g.opensaml.xmlsec.algorithm.AlgorithmDescriptor |  5 ++
 .../descriptors/KeyAgreementECDHESA128KWTest.java  | 40 ++++++++++++
 .../descriptors/KeyAgreementECDHESA192KWTest.java  | 40 ++++++++++++
 .../descriptors/KeyAgreementECDHESA256KWTest.java  | 40 ++++++++++++
 .../descriptors/KeyTransportRSAOAEP384Test.java    | 45 +++++++++++++
 .../descriptors/KeyTransportRSAOAEP512Test.java    | 45 +++++++++++++
 13 files changed, 536 insertions(+), 1 deletion(-)

diff --git a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA128KW.java b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA128KW.java
new file mode 100644
index 0000000..d00f4c4
--- /dev/null
+++ b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA128KW.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.jwa.algorithm.descriptors;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.security.crypto.JCAConstants;
+import org.opensaml.xmlsec.algorithm.KeyAgreementAlgorithm;
+
+import net.shibboleth.oidc.jwa.support.KeyManagementConstants;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+/** Algorithm descriptor for JWE key management algorithm: ECDH-ES+A128KW. */
+public class KeyAgreementECDHESA128KW implements KeyAgreementAlgorithm {
+
+    @Override
+    @Nonnull
+    @NotEmpty
+    public String getURI() {
+        return KeyManagementConstants.ALGO_ID_ALG_ECDH_ES_AES_128_KW;
+    }
+
+    @Override
+    @Nonnull
+    public AlgorithmType getType() {
+        return AlgorithmType.KeyAgreement;
+    }
+
+    @Override
+    @Nonnull
+    @NotEmpty
+    public String getJCAAlgorithmID() {
+        return JCAConstants.KEY_AGREEMENT_ECDH;
+    }
+
+
+}
diff --git a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA192KW.java b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA192KW.java
new file mode 100644
index 0000000..a07db6d
--- /dev/null
+++ b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA192KW.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.jwa.algorithm.descriptors;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.security.crypto.JCAConstants;
+import org.opensaml.xmlsec.algorithm.KeyAgreementAlgorithm;
+
+import net.shibboleth.oidc.jwa.support.KeyManagementConstants;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+/** Algorithm descriptor for JWE key management algorithm: ECDH-ES+A192KW. */
+public class KeyAgreementECDHESA192KW implements KeyAgreementAlgorithm {
+
+    @Override
+    @Nonnull
+    @NotEmpty
+    public String getURI() {
+        return KeyManagementConstants.ALGO_ID_ALG_ECDH_ES_AES_192_KW;
+    }
+
+    @Override
+    @Nonnull
+    public AlgorithmType getType() {
+        return AlgorithmType.KeyAgreement;
+    }
+
+    @Override
+    @Nonnull
+    @NotEmpty
+    public String getJCAAlgorithmID() {
+        return JCAConstants.KEY_AGREEMENT_ECDH;
+    }
+
+
+}
diff --git a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA256KW.java b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA256KW.java
new file mode 100644
index 0000000..0331293
--- /dev/null
+++ b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA256KW.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.jwa.algorithm.descriptors;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.security.crypto.JCAConstants;
+import org.opensaml.xmlsec.algorithm.KeyAgreementAlgorithm;
+
+import net.shibboleth.oidc.jwa.support.KeyManagementConstants;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+/** Algorithm descriptor for JWE key management algorithm: ECDH-ES+A256KW. */
+public class KeyAgreementECDHESA256KW implements KeyAgreementAlgorithm {
+
+    @Override
+    @Nonnull
+    @NotEmpty
+    public String getURI() {
+        return KeyManagementConstants.ALGO_ID_ALG_ECDH_ES_AES_256_KW;
+    }
+
+    @Override
+    @Nonnull
+    public AlgorithmType getType() {
+        return AlgorithmType.KeyAgreement;
+    }
+
+    @Override
+    @Nonnull
+    @NotEmpty
+    public String getJCAAlgorithmID() {
+        return JCAConstants.KEY_AGREEMENT_ECDH;
+    }
+
+
+}
diff --git a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP384.java b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP384.java
new file mode 100644
index 0000000..0a4bed6
--- /dev/null
+++ b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP384.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.jwa.algorithm.descriptors;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.security.crypto.JCAConstants;
+import org.opensaml.xmlsec.algorithm.KeyTransportAlgorithm;
+
+import net.shibboleth.oidc.jwa.support.JCAConstantExtension;
+import net.shibboleth.oidc.jwa.support.KeyManagementConstants;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+/**
+ * Algorithm descriptor for JWE key transport algorithm: RSA-OAEP-384.
+ * 
+ */
+public class KeyTransportRSAOAEP384 implements KeyTransportAlgorithm {
+
+    /** {@inheritDoc} */
+    @Nonnull
+    @NotEmpty
+    public String getKey() {
+        return JCAConstants.KEY_ALGO_RSA;
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull
+    @NotEmpty
+    public String getURI() {
+        return KeyManagementConstants.ALGO_ID_ALG_RSA_OAEP_384;
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull
+    public AlgorithmType getType() {
+        return AlgorithmType.KeyTransport;
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull
+    @NotEmpty
+    public String getJCAAlgorithmID() {
+        return String.format("%s/%s/%s", getKey(), getCipherMode(), getPadding());
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull
+    @NotEmpty
+    public String getCipherMode() {
+        return JCAConstants.CIPHER_MODE_ECB;
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull
+    @NotEmpty
+    public String getPadding() {
+        return JCAConstantExtension.CIPHER_PADDING_OAEP_384;
+    }
+
+}
diff --git a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP512.java b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP512.java
new file mode 100644
index 0000000..7e35deb
--- /dev/null
+++ b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP512.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.jwa.algorithm.descriptors;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.security.crypto.JCAConstants;
+import org.opensaml.xmlsec.algorithm.KeyTransportAlgorithm;
+
+import net.shibboleth.oidc.jwa.support.JCAConstantExtension;
+import net.shibboleth.oidc.jwa.support.KeyManagementConstants;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+/**
+ * Algorithm descriptor for JWE key transport algorithm: RSA-OAEP-512.
+ * 
+ */
+public class KeyTransportRSAOAEP512 implements KeyTransportAlgorithm {
+
+    /** {@inheritDoc} */
+    @Nonnull
+    @NotEmpty
+    public String getKey() {
+        return JCAConstants.KEY_ALGO_RSA;
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull
+    @NotEmpty
+    public String getURI() {
+        return KeyManagementConstants.ALGO_ID_ALG_RSA_OAEP_512;
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull
+    public AlgorithmType getType() {
+        return AlgorithmType.KeyTransport;
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull
+    @NotEmpty
+    public String getJCAAlgorithmID() {
+        return String.format("%s/%s/%s", getKey(), getCipherMode(), getPadding());
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull
+    @NotEmpty
+    public String getCipherMode() {
+        return JCAConstants.CIPHER_MODE_ECB;
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull
+    @NotEmpty
+    public String getPadding() {
+        return JCAConstantExtension.CIPHER_PADDING_OAEP_512;
+    }
+
+}
diff --git a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/support/JCAConstantExtension.java b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/support/JCAConstantExtension.java
index e807cf6..5e0f012 100644
--- a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/support/JCAConstantExtension.java
+++ b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/support/JCAConstantExtension.java
@@ -35,7 +35,13 @@ public final class JCAConstantExtension {
 
     /** Cipher padding "OAEP-256". */
     public static final String CIPHER_PADDING_OAEP_256 = "OAEPWithSHA-256AndMGF1Padding";
-    
+
+    /** Cipher padding "OAEP-384". */
+    public static final String CIPHER_PADDING_OAEP_384 = "OAEPWithSHA-384AndMGF1Padding";
+
+    /** Cipher padding "OAEP-512". */
+    public static final String CIPHER_PADDING_OAEP_512 = "OAEPWithSHA-512AndMGF1Padding";
+
     /** 
      * RSASSA-PSS which uses SHA256/384/512 and MGF1 functions. Note, corresponds to JWA PS* signature schemes 
      * (e.g. PS256, PS384) which all share the same JCA algorithm name. A correct {@link PSSParameterSpec} will need to 
diff --git a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/support/KeyManagementConstants.java b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/support/KeyManagementConstants.java
index a28edd4..1eea960 100644
--- a/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/support/KeyManagementConstants.java
+++ b/oidc-common-crypto-api/src/main/java/net/shibboleth/oidc/jwa/support/KeyManagementConstants.java
@@ -29,6 +29,12 @@ public final class KeyManagementConstants {
     /** Encryption - Optional RSAES OAEP using SHA-256 and MGF1 with SHA-256. */
     public static final String ALGO_ID_ALG_RSA_OAEP_256 = "RSA-OAEP-256";
 
+    /** Encryption - Optional RSAES OAEP using SHA-256 and MGF1 with SHA-384. */
+    public static final String ALGO_ID_ALG_RSA_OAEP_384 = "RSA-OAEP-384";
+
+    /** Encryption - Optional RSAES OAEP using SHA-256 and MGF1 with SHA-512. */
+    public static final String ALGO_ID_ALG_RSA_OAEP_512 = "RSA-OAEP-512";
+
     /** Encryption - Recommended AES Key Wrap with default initial value using 128-bit key. */
     public static final String ALGO_ID_ALG_AES_128_KW = "A128KW";
 
diff --git a/oidc-common-crypto-api/src/main/resources/META-INF/services/org.opensaml.xmlsec.algorithm.AlgorithmDescriptor b/oidc-common-crypto-api/src/main/resources/META-INF/services/org.opensaml.xmlsec.algorithm.AlgorithmDescriptor
index c5fd495..548c2c1 100644
--- a/oidc-common-crypto-api/src/main/resources/META-INF/services/org.opensaml.xmlsec.algorithm.AlgorithmDescriptor
+++ b/oidc-common-crypto-api/src/main/resources/META-INF/services/org.opensaml.xmlsec.algorithm.AlgorithmDescriptor
@@ -11,9 +11,14 @@ net.shibboleth.oidc.jwa.algorithm.descriptors.SignatureHS256
 net.shibboleth.oidc.jwa.algorithm.descriptors.SignatureHS384
 net.shibboleth.oidc.jwa.algorithm.descriptors.SignatureHS512
 net.shibboleth.oidc.jwa.algorithm.descriptors.KeyAgreementECDHES
+net.shibboleth.oidc.jwa.algorithm.descriptors.KeyAgreementECDHESA128KW
+net.shibboleth.oidc.jwa.algorithm.descriptors.KeyAgreementECDHESA192KW
+net.shibboleth.oidc.jwa.algorithm.descriptors.KeyAgreementECDHESA256KW
 net.shibboleth.oidc.jwa.algorithm.descriptors.KeyTransportRSA15
 net.shibboleth.oidc.jwa.algorithm.descriptors.KeyTransportRSAOAEP
 net.shibboleth.oidc.jwa.algorithm.descriptors.KeyTransportRSAOAEP256
+net.shibboleth.oidc.jwa.algorithm.descriptors.KeyTransportRSAOAEP384
+net.shibboleth.oidc.jwa.algorithm.descriptors.KeyTransportRSAOAEP512
 net.shibboleth.oidc.jwa.algorithm.descriptors.SymmetricKeyWrapA128KW
 net.shibboleth.oidc.jwa.algorithm.descriptors.SymmetricKeyWrapA192KW
 net.shibboleth.oidc.jwa.algorithm.descriptors.SymmetricKeyWrapA256KW
diff --git a/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA128KWTest.java b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA128KWTest.java
new file mode 100644
index 0000000..2a25d9a
--- /dev/null
+++ b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA128KWTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.jwa.algorithm.descriptors;
+
+import org.opensaml.xmlsec.algorithm.AlgorithmDescriptor.AlgorithmType;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import net.shibboleth.oidc.jwa.support.KeyManagementConstants;
+
+/**
+ * Unit tests for {@link KeyAgreementECDHESA128KW}
+ */
+public class KeyAgreementECDHESA128KWTest {
+
+	private final KeyAgreementECDHESA128KW algorithm = new KeyAgreementECDHESA128KW();
+
+	@Test
+	public void testInitialState() {
+		Assert.assertEquals(KeyManagementConstants.ALGO_ID_ALG_ECDH_ES_AES_128_KW, algorithm.getURI());
+		Assert.assertEquals(AlgorithmType.KeyAgreement, algorithm.getType());
+		Assert.assertEquals("ECDH", algorithm.getJCAAlgorithmID());
+	}
+
+}
\ No newline at end of file
diff --git a/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA192KWTest.java b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA192KWTest.java
new file mode 100644
index 0000000..c592ca2
--- /dev/null
+++ b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA192KWTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.jwa.algorithm.descriptors;
+
+import org.opensaml.xmlsec.algorithm.AlgorithmDescriptor.AlgorithmType;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import net.shibboleth.oidc.jwa.support.KeyManagementConstants;
+
+/**
+ * Unit tests for {@link KeyAgreementECDHESA192KW}
+ */
+public class KeyAgreementECDHESA192KWTest {
+
+	private final KeyAgreementECDHESA192KW algorithm = new KeyAgreementECDHESA192KW();
+
+	@Test
+	public void testInitialState() {
+		Assert.assertEquals(KeyManagementConstants.ALGO_ID_ALG_ECDH_ES_AES_192_KW, algorithm.getURI());
+		Assert.assertEquals(AlgorithmType.KeyAgreement, algorithm.getType());
+		Assert.assertEquals("ECDH", algorithm.getJCAAlgorithmID());
+	}
+
+}
\ No newline at end of file
diff --git a/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA256KWTest.java b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA256KWTest.java
new file mode 100644
index 0000000..1b71f59
--- /dev/null
+++ b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyAgreementECDHESA256KWTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.jwa.algorithm.descriptors;
+
+import org.opensaml.xmlsec.algorithm.AlgorithmDescriptor.AlgorithmType;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import net.shibboleth.oidc.jwa.support.KeyManagementConstants;
+
+/**
+ * Unit tests for {@link KeyAgreementECDHESA192KW}
+ */
+public class KeyAgreementECDHESA256KWTest {
+
+	private final KeyAgreementECDHESA256KW algorithm = new KeyAgreementECDHESA256KW();
+
+	@Test
+	public void testInitialState() {
+		Assert.assertEquals(KeyManagementConstants.ALGO_ID_ALG_ECDH_ES_AES_256_KW, algorithm.getURI());
+		Assert.assertEquals(AlgorithmType.KeyAgreement, algorithm.getType());
+		Assert.assertEquals("ECDH", algorithm.getJCAAlgorithmID());
+	}
+
+}
\ No newline at end of file
diff --git a/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP384Test.java b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP384Test.java
new file mode 100644
index 0000000..954a4e0
--- /dev/null
+++ b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP384Test.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.jwa.algorithm.descriptors;
+
+import net.shibboleth.oidc.jwa.support.JCAConstantExtension;
+import net.shibboleth.oidc.jwa.support.KeyManagementConstants;
+
+import org.opensaml.security.crypto.JCAConstants;
+import org.opensaml.xmlsec.algorithm.AlgorithmDescriptor.AlgorithmType;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Unit tests for {@link KeyTransportRSAOAEP384}
+ */
+public class KeyTransportRSAOAEP384Test {
+
+	private KeyTransportRSAOAEP384 algorithm = new KeyTransportRSAOAEP384();
+
+	@Test
+	public void testInitialState() {
+		Assert.assertEquals(JCAConstants.KEY_ALGO_RSA, algorithm.getKey());
+		Assert.assertEquals(KeyManagementConstants.ALGO_ID_ALG_RSA_OAEP_384, algorithm.getURI());
+		Assert.assertEquals(AlgorithmType.KeyTransport, algorithm.getType());
+		Assert.assertEquals("RSA/ECB/OAEPWithSHA-384AndMGF1Padding", algorithm.getJCAAlgorithmID());
+		Assert.assertEquals(JCAConstants.CIPHER_MODE_ECB, algorithm.getCipherMode());
+		Assert.assertEquals(JCAConstantExtension.CIPHER_PADDING_OAEP_384, algorithm.getPadding());
+	}
+
+}
\ No newline at end of file
diff --git a/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP512Test.java b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP512Test.java
new file mode 100644
index 0000000..2ed5345
--- /dev/null
+++ b/oidc-common-crypto-api/src/test/java/net/shibboleth/oidc/jwa/algorithm/descriptors/KeyTransportRSAOAEP512Test.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.jwa.algorithm.descriptors;
+
+import net.shibboleth.oidc.jwa.support.JCAConstantExtension;
+import net.shibboleth.oidc.jwa.support.KeyManagementConstants;
+
+import org.opensaml.security.crypto.JCAConstants;
+import org.opensaml.xmlsec.algorithm.AlgorithmDescriptor.AlgorithmType;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Unit tests for {@link KeyTransportRSAOAEP256}
+ */
+public class KeyTransportRSAOAEP512Test {
+
+	private KeyTransportRSAOAEP512 algorithm = new KeyTransportRSAOAEP512();
+
+	@Test
+	public void testInitialState() {
+		Assert.assertEquals(JCAConstants.KEY_ALGO_RSA, algorithm.getKey());
+		Assert.assertEquals(KeyManagementConstants.ALGO_ID_ALG_RSA_OAEP_512, algorithm.getURI());
+		Assert.assertEquals(AlgorithmType.KeyTransport, algorithm.getType());
+		Assert.assertEquals("RSA/ECB/OAEPWithSHA-512AndMGF1Padding", algorithm.getJCAAlgorithmID());
+		Assert.assertEquals(JCAConstants.CIPHER_MODE_ECB, algorithm.getCipherMode());
+		Assert.assertEquals(JCAConstantExtension.CIPHER_PADDING_OAEP_512, algorithm.getPadding());
+	}
+
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list