This is an automated email from the ASF dual-hosted git repository. elsloo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git
commit 8dabfc0c665b3fa3c0e6652b25bde1f83ebfc3d4 Author: Jesse Rivas <jesse_ri...@comcast.com> AuthorDate: Tue Feb 20 15:16:47 2018 -0700 Moved classes from core to jdnssec --- .../core/dns/keys/BindPrivateKeyFormatter.java | 56 ------------------- .../core/dns/keys/Pkcs1Formatter.java | 65 ---------------------- .../core/jdnssec/dns/keys/ZoneTestRecords.java | 18 +++++- 3 files changed, 16 insertions(+), 123 deletions(-) diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/keys/BindPrivateKeyFormatter.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/keys/BindPrivateKeyFormatter.java deleted file mode 100644 index e59b74a..0000000 --- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/keys/BindPrivateKeyFormatter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * Licensed 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 com.comcast.cdn.traffic_control.traffic_router.core.dns.keys; - -import sun.security.rsa.RSAPrivateCrtKeyImpl; - -import java.math.BigInteger; -import java.security.interfaces.RSAMultiPrimePrivateCrtKey; -import java.security.spec.RSAMultiPrimePrivateCrtKeySpec; - -import static java.util.Base64.getEncoder; - -public class BindPrivateKeyFormatter { - String encode(BigInteger bigInteger) { - return new String(getEncoder().encode(bigInteger.toByteArray())); - } - - public String format(RSAMultiPrimePrivateCrtKeySpec spec) { - return "Private-key-format: v1.2\n" + - "Algorithm: 5 (RSASHA1)\n" + - "Modulus: " + encode(spec.getModulus()) + "\n" + - "PublicExponent: " + encode(spec.getPublicExponent()) + "\n" + - "PrivateExponent: " + encode(spec.getPrivateExponent()) + "\n" + - "Prime1: " + encode(spec.getPrimeP()) + "\n" + - "Prime2: " + encode(spec.getPrimeQ()) + "\n" + - "Exponent1: " + encode(spec.getPrimeExponentP()) + "\n" + - "Exponent2: " + encode(spec.getPrimeExponentQ())+ "\n" + - "Coefficient: " + encode(spec.getCrtCoefficient())+ "\n"; - } - - public String format(RSAPrivateCrtKeyImpl key) { - return "Private-key-format: v1.2\n" + - "Algorithm: 5 (RSASHA1)\n" + - "Modulus: " + encode(key.getModulus()) + "\n" + - "PublicExponent: " + encode(key.getPublicExponent()) + "\n" + - "PrivateExponent: " + encode(key.getPrivateExponent()) + "\n" + - "Prime1: " + encode(key.getPrimeP()) + "\n" + - "Prime2: " + encode(key.getPrimeQ()) + "\n" + - "Exponent1: " + encode(key.getPrimeExponentP()) + "\n" + - "Exponent2: " + encode(key.getPrimeExponentQ())+ "\n" + - "Coefficient: " + encode(key.getCrtCoefficient())+ "\n"; - } -} diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/keys/Pkcs1Formatter.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/keys/Pkcs1Formatter.java deleted file mode 100644 index 305b2c1..0000000 --- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/keys/Pkcs1Formatter.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Licensed 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 com.comcast.cdn.traffic_control.traffic_router.core.dns.keys; - -import sun.security.rsa.RSAPrivateCrtKeyImpl; -import sun.security.util.DerOutputStream; -import sun.security.util.DerValue; - -import java.io.IOException; -import java.security.interfaces.RSAPublicKey; - -public class Pkcs1Formatter { - - // https://tools.ietf.org/html/rfc3447#appendix-A.1.1 - - public byte[] toBytes(RSAPrivateCrtKeyImpl key) throws IOException { - byte tag = 2; - DerValue[] outputSequence = new DerValue[] { - new DerValue(tag, new byte[]{0}), - new DerValue(tag, key.getModulus().toByteArray()), - new DerValue(tag, key.getPublicExponent().toByteArray()), - new DerValue(tag, key.getPrivateExponent().toByteArray()), - new DerValue(tag, key.getPrimeP().toByteArray()), - new DerValue(tag, key.getPrimeQ().toByteArray()), - new DerValue(tag, key.getPrimeExponentP().toByteArray()), - new DerValue(tag, key.getPrimeExponentQ().toByteArray()), - new DerValue(tag, key.getCrtCoefficient().toByteArray()), - }; - - DerOutputStream outputStream = new DerOutputStream(); - - outputStream.putSequence(outputSequence); - outputStream.flush(); - - return outputStream.toByteArray(); - } - - public byte[] toBytes(RSAPublicKey key) throws IOException { - byte tag = 2; - DerValue[] outputSequence = new DerValue[] { - new DerValue(tag, key.getModulus().toByteArray()), - new DerValue(tag, key.getPublicExponent().toByteArray()) - }; - - DerOutputStream outputStream = new DerOutputStream(); - - outputStream.putSequence(outputSequence); - outputStream.flush(); - - return outputStream.toByteArray(); - } -} diff --git a/traffic_router/jdnssec/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/jdnssec/dns/keys/ZoneTestRecords.java b/traffic_router/jdnssec/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/jdnssec/dns/keys/ZoneTestRecords.java index cfc25b8..dcd2c1a 100644 --- a/traffic_router/jdnssec/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/jdnssec/dns/keys/ZoneTestRecords.java +++ b/traffic_router/jdnssec/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/jdnssec/dns/keys/ZoneTestRecords.java @@ -17,11 +17,25 @@ package com.comcast.cdn.traffic_control.traffic_router.core.jdnssec.dns.keys; import com.comcast.cdn.traffic_control.traffic_router.secure.BindPrivateKey; import com.comcast.cdn.traffic_control.traffic_router.secure.Pkcs1KeySpecDecoder; -import org.xbill.DNS.*; +import org.xbill.DNS.AAAARecord; +import org.xbill.DNS.ARecord; +import org.xbill.DNS.CNAMERecord; +import org.xbill.DNS.DClass; +import org.xbill.DNS.DNSKEYRecord; +import org.xbill.DNS.NSRecord; +import org.xbill.DNS.Name; +import org.xbill.DNS.Record; +import org.xbill.DNS.TXTRecord; +import org.xbill.DNS.SOARecord; import java.net.Inet6Address; import java.net.InetAddress; -import java.security.*; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.SecureRandom; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; -- To stop receiving notification emails like this one, please contact els...@apache.org.