diff options
author | Simon Rettberg | 2014-09-29 18:15:09 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-09-29 18:15:09 +0200 |
commit | eb344e69a5613e27b1a2907f2bcab0f8367a6bde (patch) | |
tree | 0c56d0b9ab7ef8195c04e1fc8f2bee74e71b570c | |
parent | Adapt to changed Thrift RPC (diff) | |
download | masterserver-eb344e69a5613e27b1a2907f2bcab0f8367a6bde.tar.gz masterserver-eb344e69a5613e27b1a2907f2bcab0f8367a6bde.tar.xz masterserver-eb344e69a5613e27b1a2907f2bcab0f8367a6bde.zip |
Moved classes for asymmetric encryption to master-sync-shared
-rw-r--r-- | src/main/java/org/openslx/imagemaster/util/AsymMessageVerifier.java | 66 | ||||
-rw-r--r-- | src/main/java/org/openslx/imagemaster/util/ByteArray.java | 13 |
2 files changed, 0 insertions, 79 deletions
diff --git a/src/main/java/org/openslx/imagemaster/util/AsymMessageVerifier.java b/src/main/java/org/openslx/imagemaster/util/AsymMessageVerifier.java deleted file mode 100644 index e7e6be4..0000000 --- a/src/main/java/org/openslx/imagemaster/util/AsymMessageVerifier.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.openslx.imagemaster.util; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.security.InvalidKeyException; -import java.security.KeyFactory; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.PublicKey; -import java.security.Signature; -import java.security.SignatureException; -import java.security.UnrecoverableKeyException; -import java.security.cert.CertificateException; -import java.security.spec.X509EncodedKeySpec; - -import org.openslx.imagemaster.db.DbSatellite; - -public class AsymMessageVerifier -{ - - private PublicKey key; - - /** - * Load the key - * @param organization the organization to verify - * @throws Exception - * @throws NoSuchAlgorithmException - * @throws CertificateException - * @throws FileNotFoundException - * @throws IOException - * @throws KeyStoreException - * @throws UnrecoverableKeyException - */ - public AsymMessageVerifier(String organization) throws Exception - { - byte[] b = DbSatellite.getKeyfromOrganization( organization ); - - if (b == null) throw new Exception("Organization not found."); - - KeyFactory kf = KeyFactory.getInstance( "RSA" ); - X509EncodedKeySpec keySpec = new X509EncodedKeySpec(b); - key = kf.generatePublic(keySpec); - } - - /** - * Verify an encrypted message. - * - * @param messageDigest The signed message from hs/uni server - * @param expectedCleartext The message that was sent before - * @return Whether the message could be verfied or not - * @throws NoSuchAlgorithmException - * @throws InvalidKeyException - * @throws SignatureException - * @throws UnrecoverableKeyException - * @throws KeyStoreException - */ - public boolean verifyMessage( byte[] messageDigest, byte[] expectedCleartext ) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, UnrecoverableKeyException, KeyStoreException - { - // verify message - Signature signature = Signature.getInstance( "SHA256WITHRSA" ); - signature.initVerify( key ); - signature.update( expectedCleartext ); - return signature.verify( messageDigest ); - } - -} diff --git a/src/main/java/org/openslx/imagemaster/util/ByteArray.java b/src/main/java/org/openslx/imagemaster/util/ByteArray.java deleted file mode 100644 index 71244a9..0000000 --- a/src/main/java/org/openslx/imagemaster/util/ByteArray.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.openslx.imagemaster.util; - - -public class ByteArray -{ - - public final byte[] array; - - public ByteArray(byte[] array) - { - this.array = array; - } -}
\ No newline at end of file |