# Overview

This library contains the mock implementation of Security LLAPI: based on the JRE cryptography.

# Usage

Add the following dependency to your `build.gradle.kts`:

	microejMock("com.microej.pack.crypto:crypto-mock:<version>")

## Properties

The mock reads the following system properties from the host JVM. To forward
them from a simulator launch, prefix each with `microej.mock.property.` in the
application's launch configuration (e.g. `microej.mock.property.ej.crypto.mock.debug=true`).

### Custom JCA provider

| Property                          | Default | Description                                                                                                                                            |
| --------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ej.crypto.mock.security.provider`| _(none)_| Fully-qualified class name of a `java.security.Provider` to instantiate (no-arg constructor) and register at mock init. Example: `org.bouncycastle.jce.provider.BouncyCastleProvider`. |

### External KeyStore

| Property                        | Default   | Description                                                                                                                  |
| ------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `ej.crypto.mock.externalks.path`| _(none)_  | Path to the host-filesystem keystore file backing `ExternalKeyStoreNatives`. If unset, the mock uses an empty keystore.       |
| `ej.crypto.mock.externalks.type`| `PKCS12`  | KeyStore type passed to `KeyStore.getInstance(type)`.                                                                         |
| `ej.crypto.mock.externalks.pub` | `false`   | When `true`, `getKey()` falls back to returning the certificate's public key if no private/secret key is found for the alias. |

### Debug logging

A master switch enables debug traces in every area; each area can also be toggled individually.

| Property                              | Default | Area                                  |
| ------------------------------------- | ------- | ------------------------------------- |
| `ej.crypto.mock.debug`                | `false` | Master switch — enables all areas below. |
| `ej.crypto.mock.init.debug`           | `false` | `NativeSecurityProvider` initialization. |
| `ej.crypto.mock.cipher.debug`         | `false` | `NativeCipherSpi`.                    |
| `ej.crypto.mock.keyagreement.debug`   | `false` | `KeyAgreementNatives`.                |
| `ej.crypto.mock.keystore.debug`       | `false` | `ExternalKeyStoreNatives`.            |
| `com.microej.security.keyfactory.debug` | `false` | `NativeKeyFactorySpi` (not covered by the master switch). |

# Requirements

# Dependencies

_All dependencies are retrieved transitively by Gradle_.

# Source

N/A.

# Restrictions

None.

---

_Copyright 2018-2026 MicroEJ Corp. All rights reserved._
_This library is provided in source code for use, modification and test, subject to license terms._
_Any modification of the source code will break MicroEJ Corp. warranties on the whole library._
