summaryrefslogtreecommitdiffstats
path: root/base/common/src/org
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2017-03-15 17:19:01 -0400
committerAde Lee <alee@redhat.com>2017-03-21 18:49:07 -0400
commit82478227debddbe11bd9b9eeb0e1e2f3bd5282fb (patch)
tree62418ffdfff9d90cec9ca6749f0524a83bf41233 /base/common/src/org
parentf40e0d002e57cadd5dc254d096db52de439ed900 (diff)
downloadpki-82478227debddbe11bd9b9eeb0e1e2f3bd5282fb.tar.gz
pki-82478227debddbe11bd9b9eeb0e1e2f3bd5282fb.tar.xz
pki-82478227debddbe11bd9b9eeb0e1e2f3bd5282fb.zip
Fix Java client to use AES
* Changed the client to use AES-128-CBC-PAD rather than DES-3. Because AES-256-CBC-PAD has no OID defined, we use the following hack: * Pass in the AES-256-CBC OID as the encrypt algorithm OID * Use PKCS#1.5 Padding. * Changed the client to use AES for the wrapping key on retrieval. * Changed the server to implicitly assume PKCS#1.5 (and a key size of 128) when recieving the OID for AES. * Changed the client to send, and the server to pass through the encryption algorithm expected when retrieving the key. * Fixed the generate_iv() function to generate an appropriately sized IV on retrieval. This code has been tested to successfully create and retrieve secrets using AES. Ideally, we'd be using GCM rather than CBC, which then requires no padding - and no hack needed. Hopefully, we can get that working in a subsequent commit. Change-Id: Ic9e8d50169be0fe357a48a5a1b1c452c7a3dfad0
Diffstat (limited to 'base/common/src/org')
-rw-r--r--base/common/src/org/dogtagpki/common/Version.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/base/common/src/org/dogtagpki/common/Version.java b/base/common/src/org/dogtagpki/common/Version.java
new file mode 100644
index 000000000..4f87e07ec
--- /dev/null
+++ b/base/common/src/org/dogtagpki/common/Version.java
@@ -0,0 +1,85 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2017 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package org.dogtagpki.common;
+
+public class Version {
+
+ private int major;
+ private int minor;
+ private int micro;
+
+ public Version(String version) {
+ String[] parts = version.split("[.]");
+ major = Integer.valueOf(parts[0]);
+
+ if (parts.length > 1) {
+ minor = Integer.valueOf(parts[1]);
+ }
+ if (parts.length > 2) {
+ micro = Integer.valueOf(parts[2]);
+ }
+ }
+
+ public int getMajor() {
+ return major;
+ }
+
+ public void setMajor(int major) {
+ this.major = major;
+ }
+
+ public int getMinor() {
+ return minor;
+ }
+
+ public void setMinor(int minor) {
+ this.minor = minor;
+ }
+
+ public int getMicro() {
+ return micro;
+ }
+
+ public void setMicro(int micro) {
+ this.micro = micro;
+ }
+
+ public static void main(String args[]) throws Exception {
+ Version version = new Version("10.4.0");
+ if (version.getMajor() != 10) System.out.println("Error in getting major");
+ if (version.getMinor() != 4) System.out.println("Error in getting minor");
+ if (version.getMicro() != 0) System.out.println("Error in getting micro");
+
+ version = new Version("9.1");
+ if (version.getMajor() != 9) System.out.println("Error in getting major");
+ if (version.getMinor() != 1) System.out.println("Error in getting minor");
+ if (version.getMicro() != 0) System.out.println("Error in getting micro");
+
+ version = new Version("4");
+ if (version.getMajor() != 4) System.out.println("Error in getting major");
+ if (version.getMinor() != 0) System.out.println("Error in getting minor");
+ if (version.getMicro() != 0) System.out.println("Error in getting micro");
+
+ version = new Version("8.53.2.6");
+ if (version.getMajor() != 8) System.out.println("Error in getting major");
+ if (version.getMinor() != 53) System.out.println("Error in getting minor");
+ if (version.getMicro() != 2) System.out.println("Error in getting micro");
+ }
+
+}