java/remoteprovisioning/CborUtil.java
/**
   * Encodes and encrypts a COSE_Encrypt message, provided a plaintext payload and corresponding
   * keys.
   *
   * @param plaintext the plaintext payload to be encrypted.
   * @param ephemeralKeyPair the ephemeral public key to be used in the X25519 operation.
   * @param eek the server key pair to be used in the X25519 operation.
   * @return a COSE_Encrypt message encoded in a CBORObject
   */
Encodes and encrypts a COSE_Encrypt message, provided a plaintext payload and corresponding
keys.

@param plaintext the plaintext payload to be encrypted.
@param ephemeralKeyPair the ephemeral public key to be used in the X25519 operation.
@param eek the server key pair to be used in the X25519 operation.
@return a COSE_Encrypt message encoded in a CBORObject
Encodes and encrypts a COSE_Encrypt message provided a plaintext payload and corresponding keys . @param plaintext the plaintext payload to be encrypted . @param ephemeralKeyPair the ephemeral public key to be used in the X25519 operation . @param eek the server key pair to be used in the X25519 operation . @return a COSE_Encrypt message encoded in a CBORObject
public static CBORObject encodeEncryptMessage(
      byte[] plaintext, AsymmetricCipherKeyPair ephemeralKeyPair, X25519PublicKeyParameters eek)
      throws CborException, CryptoException {
    byte[] sendKey = CryptoUtil.deriveSharedKeySend(ephemeralKeyPair, eek);
    CBORObject ephemeralPubKey =
        CryptoUtil.x25519ToOneKey(
            (X25519PublicKeyParameters) ephemeralKeyPair.getPublic()).AsCBOR();
    byte[] keyId = CryptoUtil.digestX25519(eek);
    return encodeEncryptMessageInternal(plaintext, sendKey, ephemeralPubKey, keyId);
  }
public static CBORObject encodeEncryptMessage ( byte [ ] plaintext , AsymmetricCipherKeyPair ephemeralKeyPair , X25519PublicKeyParameters eek ) throws CborException , CryptoException { byte [ ] sendKey = CryptoUtil . deriveSharedKeySend ( ephemeralKeyPair , eek ) ; CBORObject ephemeralPubKey = CryptoUtil . x25519ToOneKey ( ( X25519PublicKeyParameters ) ephemeralKeyPair . getPublic ( ) ) . AsCBOR ( ) ; byte [ ] keyId = CryptoUtil . digestX25519 ( eek ) ; return encodeEncryptMessageInternal ( plaintext , sendKey , ephemeralPubKey , keyId ) ; }
Encodes and encrypts a COSE_Encrypt message, provided a plaintext payload and corresponding
 keys.
Encodes and encrypts a COSE_Encrypt message provided a plaintext payload and corresponding keys .