mil.dod.th.ose.remote/src/mil/dod/th/ose/remote/api/EncryptionUtility.java
public static byte[] sharedEcdhKeyCreate(final ECPrivateKeyParameters localPrivateKey, 
                      final ECPublicKeyParameters remotePublicKey, final int localSystemId, final int remoteSystemId)
    {
        //set up basic key agreement
        final ECDHBasicAgreement basicAgreement = new ECDHBasicAgreement();
        basicAgreement.init(localPrivateKey);
        final BigInteger secret = basicAgreement.calculateAgreement(remotePublicKey);
        final byte[] sharedSecret = BigIntegers.asUnsignedByteArray(secret);
        final String hashAlg = "SHA256";
        //Normally this should have been (256/8 = 32bytes),however, as per Nist
        //this is truncated to 16 bytes.
        final int keyDataLen = 16;
        //buffer capacity in bytes(4)
        final int bufferCapacity = 4;
        //few things like algorithm id = 1 are hard coded.
        final byte[] algorithmID = ByteBuffer.allocate(bufferCapacity).putInt(1).array();
        final byte[] partyUInfo = ByteBuffer.allocate(bufferCapacity).putInt(localSystemId).array();
        final byte[] partyVInfo = ByteBuffer.allocate(bufferCapacity).putInt(remoteSystemId).array();
        return concatKDF(hashAlg, sharedSecret, keyDataLen, algorithmID, partyUInfo, partyVInfo);
    }
/**
     * utility function for creating shared secret kdf key based on private and public key 
     * from local and remote systems.
     * @param localPrivateKey
     *       local private key
     * @param remotePublicKey
     *      Remote public key
     * @param localSystemId
     *      local system Id
     * @param remoteSystemId
     *     remote system Id
     * @return byte[]
     *      The shared secret key formed after kdf.
     */
utility function for creating shared secret kdf key based on private and public key
from local and remote systems.
utility function for creating shared secret kdf key based on private and public key from local and remote systems .
public static byte[] sharedEcdhKeyCreate(final ECPrivateKeyParameters localPrivateKey, 
                      final ECPublicKeyParameters remotePublicKey, final int localSystemId, final int remoteSystemId)
    {
        final ECDHBasicAgreement basicAgreement = new ECDHBasicAgreement();
        basicAgreement.init(localPrivateKey);
        final BigInteger secret = basicAgreement.calculateAgreement(remotePublicKey);
        final byte[] sharedSecret = BigIntegers.asUnsignedByteArray(secret);
        final String hashAlg = "SHA256";
        final int keyDataLen = 16;
        final int bufferCapacity = 4;
        final byte[] algorithmID = ByteBuffer.allocate(bufferCapacity).putInt(1).array();
        final byte[] partyUInfo = ByteBuffer.allocate(bufferCapacity).putInt(localSystemId).array();
        final byte[] partyVInfo = ByteBuffer.allocate(bufferCapacity).putInt(remoteSystemId).array();
        return concatKDF(hashAlg, sharedSecret, keyDataLen, algorithmID, partyUInfo, partyVInfo);
    }
public static byte [ ] sharedEcdhKeyCreate ( final ECPrivateKeyParameters localPrivateKey , final ECPublicKeyParameters remotePublicKey , final int localSystemId , final int remoteSystemId ) { final ECDHBasicAgreement basicAgreement = new ECDHBasicAgreement ( ) ; basicAgreement . init ( localPrivateKey ) ; final BigInteger secret = basicAgreement . calculateAgreement ( remotePublicKey ) ; final byte [ ] sharedSecret = BigIntegers . asUnsignedByteArray ( secret ) ; final String hashAlg = "SHA256" ; final int keyDataLen = 16 ; final int bufferCapacity = 4 ; final byte [ ] algorithmID = ByteBuffer . allocate ( bufferCapacity ) . putInt ( 1 ) . array ( ) ; final byte [ ] partyUInfo = ByteBuffer . allocate ( bufferCapacity ) . putInt ( localSystemId ) . array ( ) ; final byte [ ] partyVInfo = ByteBuffer . allocate ( bufferCapacity ) . putInt ( remoteSystemId ) . array ( ) ; return concatKDF ( hashAlg , sharedSecret , keyDataLen , algorithmID , partyUInfo , partyVInfo ) ; }
utility function for creating shared secret kdf key based on private and public key
 from local and remote systems.
utility function for creating shared secret kdf key based on private and public key from local and remote systems .
//set up basic key agreement //Normally this should have been (256/8 = 32bytes),however, as per Nist //this is truncated to 16 bytes. //buffer capacity in bytes(4) //few things like algorithm id = 1 are hard coded.