Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class PortCryptoEngine

  1. Object
  2. CryptoEngine
  3. PortCryptoEngine
The client’s default CryptoEngine: PBKDF2 goes to the port’s native derivation (CodenameOneImplementation.pbkdf2), everything else runs in Java, and the asynchronous CryptoBatch calls answer on the EDT. A port with more native kernels subclasses it.

Constructors

public PortCryptoEngine(CodenameOneImplementation impl)Creates the engine over a port.

Methods

public boolean randomBytes(byte[] out)Fills out with bytes from the platform’s CSPRNG, answering false when this engine has no source.
public void deliver(Runnable result)Runs the callback of an asynchronous CryptoBatch call on the EDT.
public byte[] pbkdf2(String hashAlgorithm, byte[] password, byte[] salt, int iterations, int length)PBKDF2 (RFC 8018) with HMAC over hashAlgorithm (Hash.SHA256 or Hash.SHA512), or null to use the Java derivation.

Inherited fields

Inherited methods

Constructor details

PortCryptoEngine

public PortCryptoEngine(CodenameOneImplementation impl)
Creates the engine over a port.

Parameters

impl CodenameOneImplementation
the port whose native derivation PBKDF2 uses

Method details

randomBytes

public boolean randomBytes(byte[] out)
Fills out with bytes from the platform’s CSPRNG, answering false when this engine has no source. Every installed engine has one: the client’s draws on the port, the backend’s on the server runtime.

deliver

public void deliver(Runnable result)
Runs the callback of an asynchronous CryptoBatch call on the EDT.

Parameters

result Runnable
the call to the application’s callback

pbkdf2

public byte[] pbkdf2(String hashAlgorithm, byte[] password, byte[] salt, int iterations, int length)
PBKDF2 (RFC 8018) with HMAC over hashAlgorithm (Hash.SHA256 or Hash.SHA512), or null to use the Java derivation. The arguments are already validated.