diff options
author | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
commit | 171aaece4f23709d33d180cf36eb3af5e454b0c9 (patch) | |
tree | 1485f9f0a7bd10de4ff25030db575dbb8dafae74 /pki/base/symkey/src/com/netscape/symkey/SessionKey.java | |
parent | adad2fcee8a29fdb82376fbce07dedb11fccc182 (diff) | |
download | pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.gz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.xz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.zip |
Revert "Formatting"
This reverts commit 32150d3ee32f8ac27118af7c792794b538c78a2f.
Diffstat (limited to 'pki/base/symkey/src/com/netscape/symkey/SessionKey.java')
-rw-r--r-- | pki/base/symkey/src/com/netscape/symkey/SessionKey.java | 179 |
1 files changed, 109 insertions, 70 deletions
diff --git a/pki/base/symkey/src/com/netscape/symkey/SessionKey.java b/pki/base/symkey/src/com/netscape/symkey/SessionKey.java index 562bc30c5..3a00c8351 100644 --- a/pki/base/symkey/src/com/netscape/symkey/SessionKey.java +++ b/pki/base/symkey/src/com/netscape/symkey/SessionKey.java @@ -18,18 +18,22 @@ package com.netscape.symkey; + import org.mozilla.jss.pkcs11.PK11SymKey; + /** - * This object contains the OS independent interfaces. + * This object contains the OS independent interfaces. */ -public class SessionKey { - static boolean tryLoad(String filename) { +public class SessionKey +{ + static boolean tryLoad( String filename ) + { try { - System.load(filename); - } catch (Exception e) { + System.load( filename ); + } catch( Exception e ) { return false; - } catch (UnsatisfiedLinkError e) { + } catch( UnsatisfiedLinkError e ) { return false; } @@ -39,67 +43,86 @@ public class SessionKey { // Load native library static { boolean mNativeLibrariesLoaded = false; - String os = System.getProperty("os.name"); - if ((os.equals("Linux"))) { + String os = System.getProperty( "os.name" ); + if( ( os.equals( "Linux" ) ) ) { // Check for 64-bit library availability // prior to 32-bit library availability. - mNativeLibrariesLoaded = tryLoad("/usr/lib64/symkey/libsymkey.so"); - if (mNativeLibrariesLoaded) { - System.out.println("64-bit symkey library loaded"); + mNativeLibrariesLoaded = + tryLoad( "/usr/lib64/symkey/libsymkey.so" ); + if( mNativeLibrariesLoaded ) { + System.out.println( "64-bit symkey library loaded" ); } else { - // REMINDER: May be trying to run a 32-bit app - // on 64-bit platform. - mNativeLibrariesLoaded = tryLoad("/usr/lib/symkey/libsymkey.so"); - if (mNativeLibrariesLoaded) { - System.out.println("32-bit symkey library loaded"); + // REMINDER: May be trying to run a 32-bit app + // on 64-bit platform. + mNativeLibrariesLoaded = + tryLoad( "/usr/lib/symkey/libsymkey.so" ); + if( mNativeLibrariesLoaded ) { + System.out.println( "32-bit symkey library loaded"); } else { - System.out.println("FAILED loading symkey library!"); - System.exit(-1); + System.out.println( "FAILED loading symkey library!"); + System.exit( -1 ); } } } else { try { - System.loadLibrary("symkey"); - System.out.println("symkey library loaded"); + System.loadLibrary( "symkey" ); + System.out.println( "symkey library loaded" ); mNativeLibrariesLoaded = true; - } catch (Throwable t) { + } catch( Throwable t ) { // This is bad news, the program is doomed at this point t.printStackTrace(); } } } - // external calls from RA - public static native byte[] ComputeKeyCheck(PK11SymKey desKey); /* - * byte - * data[] ); - */ - - public static native byte[] ComputeSessionKey(String tokenName, - String keyName, byte[] card_challenge, byte[] host_challenge, - byte[] keyInfo, byte[] CUID, byte[] macKeyArray, - String useSoftToken, String keySet, String sharedSecretKeyName); - - public static native byte[] ComputeEncSessionKey(String tokenName, - String keyName, byte[] card_challenge, byte[] host_challenge, - byte[] keyInfo, byte[] CUID, byte[] encKeyArray, - String useSoftToken, String keySet); - - public static native PK11SymKey ComputeKekSessionKey(String tokenName, - String keyName, byte[] card_challenge, byte[] host_challenge, - byte[] keyInfo, byte[] CUID, byte[] kekKeyArray, - String useSoftToken, String keySet); - public static native PK11SymKey ComputeKekKey(String tokenName, - String keyName, byte[] card_challenge, byte[] host_challenge, - byte[] keyInfo, byte[] CUID, byte[] kekKeyArray, - String useSoftToken, String keySet); - - public static native byte[] ECBencrypt(PK11SymKey key, PK11SymKey desKey); // byte[] - // data - // ); - - public static native PK11SymKey GenerateSymkey(String tokenName); + // external calls from RA + public static native byte[] ComputeKeyCheck(PK11SymKey desKey ); /* byte data[] ); */ + + public static native byte[] ComputeSessionKey( String tokenName, + String keyName, + byte[] card_challenge, + byte[] host_challenge, + byte[] keyInfo, + byte[] CUID, + byte[] macKeyArray, + String useSoftToken, + String keySet, + String sharedSecretKeyName ); + + public static native byte[] ComputeEncSessionKey( String tokenName, + String keyName, + byte[] card_challenge, + byte[] host_challenge, + byte[] keyInfo, + byte[] CUID, + byte[] encKeyArray, + String useSoftToken, + String keySet ); + + public static native PK11SymKey ComputeKekSessionKey( String tokenName, + String keyName, + byte[] card_challenge, + byte[] host_challenge, + byte[] keyInfo, + byte[] CUID, + byte[] kekKeyArray, + String useSoftToken, + String keySet ); + + public static native PK11SymKey ComputeKekKey( String tokenName, + String keyName, + byte[] card_challenge, + byte[] host_challenge, + byte[] keyInfo, + byte[] CUID, + byte[] kekKeyArray, + String useSoftToken, String keySet ); + + public static native byte[] ECBencrypt( PK11SymKey key, + PK11SymKey desKey ); //byte[] data ); + + public static native PK11SymKey GenerateSymkey( String tokenName ); /* * DRM_SUPPORT_DEBUG @@ -107,28 +130,44 @@ public class SessionKey { // public static native PK11SymKey bytes2PK11SymKey( byte[] symKeyBytes ); - public static native byte[] ComputeCryptogram(String tokenName, - String keyName, byte[] card_challenge, byte[] host_challenge, - byte[] keyInfo, byte[] CUID, int type, byte[] authKeyArray, - String useSoftToken, String keySet); - - public static native byte[] EncryptData(String tokenName, String keyName, - byte[] in, byte[] keyInfo, byte[] CUID, byte[] kekKeyArray, - String useSoftToken, String keySet); - - public static native byte[] DiversifyKey(String tokenName, - String newTokenName, String oldMasterKeyName, - String newMasterKeyName, String keyInfo, byte[] CUIDValue, - byte[] kekKeyArray, String useSoftToken, String keySet); + public static native byte[] ComputeCryptogram( String tokenName, + String keyName, + byte[] card_challenge, + byte[] host_challenge, + byte[] keyInfo, + byte[] CUID, + int type, + byte[] authKeyArray, + String useSoftToken, String keySet ); + + public static native byte[] EncryptData( String tokenName, + String keyName, + byte[] in, + byte[] keyInfo, + byte[] CUID, + byte[] kekKeyArray, + String useSoftToken, String keySet ); + + public static native byte[] DiversifyKey( String tokenName, + String newTokenName, + String oldMasterKeyName, + String newMasterKeyName, + String keyInfo, + byte[] CUIDValue, + byte[] kekKeyArray, + String useSoftToken, String keySet ); // internal calls from config TKS keys tab - public static native String GenMasterKey(String token, String keyName); + public static native String GenMasterKey( String token, + String keyName ); - public static native String DeleteSymmetricKey(String token, String keyName); + public static native String DeleteSymmetricKey( String token, + String keyName ); - public static native String ListSymmetricKeys(String token); + public static native String ListSymmetricKeys( String token ); - // set when called from the config TKS tab to create master key - // get when called from the RA to create session key - public static native void SetDefaultPrefix(String masterPrefix); + // set when called from the config TKS tab to create master key + // get when called from the RA to create session key + public static native void SetDefaultPrefix( String masterPrefix ); } + |