Skip to main content

decoder_side_device

using Eclypses.EcdhP256;

public byte[] GetEntropyForMTEEncoder() {
// Create Eclypses DH.
EcdhP256 ecdh = new EcdhP256();

// Create key pair and retrieve the public key.
byte[] publicKey = new byte[EcdhP256.SzPublicKey];
int res = ecdh.CreateKeyPair(publicKey);
if (res < 0) {
throw new Exception("Unable to create key pair: " + res);
}

// Send public key to Decoder side and get back
// Decoder side public key.
//---------------------------------------------------------
// This method is not included in this sample!!!
// This is here only to demonstrate that the user MUST
// send the public key to other side and receive back the
// public key from the other side.
//---------------------------------------------------------
byte[] partnerPublicKey = SendPublicKeyGetPartnerPublicKey(publicKey);

// Create the shared secret with the public key received from the Decoder.
byte[] sharedSecret = new byte[EcdhP256.SzSecretData];
res = ecdh.GetSharedSecret(partnerPublicKey, sharedSecret);
if (res < 0) {
throw new Exception("Unable to create shared secret: " + res);
}

// Return the shared secret so it can be used as the entropy value
// when creating the MTE Encoder within the calling program.
return sharedSecret;
}