java.lang.Object | |
↳ | com.samsung.android.knox.ucm.core.SecureChannelManager |
This class provides ability to use secure channel.
API level 20 |
KNOX 2.7 |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | BUNDLE_EXTRA_SCP_ENCRYPTION | This constant defines Bundle Extra for key usage, encryption is enabled. | |||||||||
String | BUNDLE_EXTRA_SCP_KEY_ID | This constant defines Bundle Extra for key id. | |||||||||
String | BUNDLE_EXTRA_SCP_KEY_LENGTH | This constant defines Bundle Extra for key length of AES/MAC key for message encryption and C-MAC generation. | |||||||||
String | BUNDLE_EXTRA_SCP_KEY_PARAM_DH_G | This constant defines Bundle Extra for Byte array of Diffie-Hellman generator for key agreement. | |||||||||
String | BUNDLE_EXTRA_SCP_KEY_PARAM_DH_P | This constant defines Bundle Extra for prime number needed for key agreement (Diffie-Hellman). | |||||||||
String | BUNDLE_EXTRA_SCP_KEY_PARAM_ECC | This constant defines Bundle Extra for ECC curve id for key agreement Note: SCP11A/B only. |
|||||||||
String | BUNDLE_EXTRA_SCP_KEY_VERSION | This constant defines Bundle Extra for key version. | |||||||||
String | BUNDLE_EXTRA_SCP_MAC | This constant defines Bundle Extra for key usage, MAC for message authentication. | |||||||||
String | BUNDLE_EXTRA_SCP_PROTOCOL | This constant defines Bundle Extra for secure channel protocol id. | |||||||||
int | BUNDLE_SCP_KEY_PARAM_ECC_FRP_P256 | This constant defines value for ECC curve spec FRP-P256. | |||||||||
int | BUNDLE_SCP_KEY_PARAM_ECC_NIST_P256 | This constant defines value for ECC curve spec NIST-P256. | |||||||||
int | ERROR_APDU_PARSING | This error constant is returned due to APDU parsing error. | |||||||||
int | ERROR_CA_CERT_NOT_FOUND | This error constant is returned due to no CA cert found. | |||||||||
int | ERROR_CHANNEL_NOT_FOUND | This error constant is returned when Secure Channel is not found. | |||||||||
int | ERROR_DEVICE_COMPROMISED | This error constant is returned due to Device compromised. | |||||||||
int | ERROR_INTERNAL | This error constant is returned due to internal processing error. | |||||||||
int | ERROR_INTERNAL_CRYPTO_FAILED | This error constant is returned due to Crypto operation failed. | |||||||||
int | ERROR_INVALID_MESSAGE_TYPE | This error constant is returned due to invalid message type. | |||||||||
int | ERROR_INVALID_PERMISSION | This error constant is returned due to invalid permission. | |||||||||
int | ERROR_INVALID_PROTOCOL | This error constant is returned due to invalid protocol. | |||||||||
int | ERROR_INVALID_SD_CERT | This error constant is returned due to invalid SD cert. | |||||||||
int | ERROR_INVALID_SD_MAC | This error constant is returned due to invalid SD MAC. | |||||||||
int | ERROR_INVALID_SD_RECEIPT | This error constant is returned due to invalid SD receipt. | |||||||||
int | ERROR_NOT_SUPPORTED_CURVE | This error constant is returned due to no supported curve. | |||||||||
int | ERROR_NO_INTERNAL_MEMORY | This error constant is returned due to No internal memory. | |||||||||
int | ERROR_SD_CERT_NOT_FOUND | This error constant is returned due to no SD cert found. | |||||||||
int | ERROR_TLV_PARSING | This error constant is returned due to TLC parsing error. | |||||||||
int | ERROR_TZ_APP_CONNECTION_FAILED | This error constant is returned due to TZ APP connection failed. | |||||||||
int | MESSAGE_TYPE_COMMAND | processMessage(int, byte[]) API message type - "Command" for SCP communication. |
|||||||||
int | MESSAGE_TYPE_FORWARD_TO_SD | ApduMessage message type - "Forward to SD" for SCP communication. |
|||||||||
int | MESSAGE_TYPE_PROCESSING_COMPLETED | ApduMessage message type - "Completed" for SCP communication. |
|||||||||
int | MESSAGE_TYPE_RESPONSE | processMessage(int, byte[]) API message type - "Response" for SCP communication. |
|||||||||
int | MESSAGE_TYPE_SECURE_CHANNEL | processMessage(int, byte[]) API message type - "Channel" for SCP communication. |
|||||||||
int | PROTOCOL_TYPE_SCP11A | createSecureChannel(int, Bundle) API protocol type - "SCP11A" for SCP communication. |
|||||||||
int | PROTOCOL_TYPE_SCP11B | createSecureChannel(int, Bundle) API protocol type - "SCP11B" for SCP communication. |
|||||||||
int | PROTOCOL_TYPE_SCP_CUSTOM | createSecureChannel(int, Bundle) API protocol type - "SCP custom" for SCP communication. |
|||||||||
int | PROTOCOL_TYPE_SCP_OTHER | createSecureChannel(int, Bundle) API protocol type - "SCP other" for SCP communication. |
|||||||||
int | STATUS_FAILURE | ApduMessage Status - Failure |
|||||||||
int | STATUS_SC_CONSTRUCTED | ApduMessage Status - Secure Channel constructed. |
|||||||||
int | STATUS_SC_REQUIRED | ApduMessage Status - Secure Channel required. |
|||||||||
int | STATUS_SUCCESS | ApduMessage Status - Success |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
API to Create secure channel via SCP11.
| |||||||||||
API to destroy secure channel.
| |||||||||||
Retrieve SecureChannelManager Instance which can interact with KNOX Credential Storage.
| |||||||||||
API to Process message via SCP11.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
This constant defines Bundle Extra for key usage, encryption is enabled.
Note: Encryption is by default enabled, not allowed to be disabled.
API level 20 |
KNOX 2.7 |
This constant defines Bundle Extra for key id.
API level 20 |
KNOX 2.7 |
This constant defines Bundle Extra for key length of AES/MAC key for message encryption and C-MAC generation.
Note: Key length is fixed as 256bit, not allowed to be changed.
API level 20 |
KNOX 2.7 |
This constant defines Bundle Extra for Byte array of Diffie-Hellman generator for key agreement.
Note: SCP11B_CUSTOM only. SCP11A and B uses ECC, will ignore DH-P/G.
API level 20 |
KNOX 2.7 |
This constant defines Bundle Extra for prime number needed for key agreement (Diffie-Hellman).
Note: SCP11B_CUSTOM only. SCP11A and B uses ECC, will ignore DH-P/G.
API level 20 |
KNOX 2.7 |
This constant defines Bundle Extra for ECC curve id for key agreement
Note: SCP11A/B only.
API level 20 |
KNOX 2.7 |
This constant defines Bundle Extra for key version.
API level 20 |
KNOX 2.7 |
This constant defines Bundle Extra for key usage, MAC for message authentication.
Note: MAC is by default enabled, not allowed to be disabled.
API level 20 |
KNOX 2.7 |
This constant defines Bundle Extra for secure channel protocol id.
API level 20 |
KNOX 2.7 |
This constant defines value for ECC curve spec FRP-P256.
API level 20 |
KNOX 2.7 |
This constant defines value for ECC curve spec NIST-P256.
API level 20 |
KNOX 2.7 |
This error constant is returned due to APDU parsing error.
API level 20 |
KNOX 2.7 |
This error constant is returned due to no CA cert found.
API level 20 |
KNOX 2.7 |
This error constant is returned when Secure Channel is not found.
API level 20 |
KNOX 2.7 |
This error constant is returned due to Device compromised.
API level 20 |
KNOX 2.7 |
This error constant is returned due to internal processing error.
API level 20 |
KNOX 2.7 |
This error constant is returned due to Crypto operation failed.
API level 20 |
KNOX 2.7 |
This error constant is returned due to invalid message type.
API level 20 |
KNOX 2.7 |
This error constant is returned due to invalid permission.
API level 20 |
KNOX 2.7 |
This error constant is returned due to invalid protocol.
API level 20 |
KNOX 2.7 |
This error constant is returned due to invalid SD cert.
API level 20 |
KNOX 2.7 |
This error constant is returned due to invalid SD MAC.
API level 20 |
KNOX 2.7 |
This error constant is returned due to invalid SD receipt.
API level 20 |
KNOX 2.7 |
This error constant is returned due to no supported curve.
API level 20 |
KNOX 2.7 |
This error constant is returned due to No internal memory.
API level 20 |
KNOX 2.7 |
This error constant is returned due to no SD cert found.
API level 20 |
KNOX 2.7 |
This error constant is returned due to TLC parsing error.
API level 20 |
KNOX 2.7 |
This error constant is returned due to TZ APP connection failed.
API level 20 |
KNOX 2.7 |
processMessage(int, byte[])
API message type - "Command" for SCP communication.
API level 20 |
KNOX 2.7 |
ApduMessage
message type - "Forward to SD" for SCP communication.
API level 20 |
KNOX 2.7 |
ApduMessage
message type - "Completed" for SCP communication.
API level 20 |
KNOX 2.7 |
processMessage(int, byte[])
API message type - "Response" for SCP communication.
API level 20 |
KNOX 2.7 |
processMessage(int, byte[])
API message type - "Channel" for SCP communication.
API level 20 |
KNOX 2.7 |
createSecureChannel(int, Bundle)
API protocol type - "SCP11A" for SCP communication.
API level 20 |
KNOX 2.7 |
createSecureChannel(int, Bundle)
API protocol type - "SCP11B" for SCP communication.
API level 20 |
KNOX 2.7 |
createSecureChannel(int, Bundle)
API protocol type - "SCP custom" for SCP communication.
API level 20 |
KNOX 2.7 |
createSecureChannel(int, Bundle)
API protocol type - "SCP other" for SCP communication.
API level 20 |
KNOX 2.7 |
ApduMessage
Status - Secure Channel constructed.
API level 20 |
KNOX 2.7 |
ApduMessage
Status - Secure Channel required.
API level 20 |
KNOX 2.7 |
API to Create secure channel via SCP11.
protocolType | PROTOCOL_TYPE_SCP11A , PROTOCOL_TYPE_SCP11B , PROTOCOL_TYPE_SCP_CUSTOM , PROTOCOL_TYPE_SCP_OTHER |
---|---|
bundle | SCP options |
An application can use this API to Create secure channel via SCP11.
try { Bundle bundle = new Bundle(); bundle.putInt(SecureChannelManager.BUNDLE_EXTRA_SCP_PROTOCOL, SecureChannelManager.PROTOCOL_TYPE_SCP11B); bundle.putInt(SecureChannelManager.BUNDLE_EXTRA_SCP_KEY_ID, 0); bundle.putInt(SecureChannelManager.BUNDLE_EXTRA_SCP_KEY_ID, 1); bundle.putInt(SecureChannelManager.BUNDLE_EXTRA_SCP_KEY_LENGTH, keyLength); // must be 0x20 : AES256 bundle.putBoolean(SecureChannelManager.BUNDLE_EXTRA_SCP_ENCRYPTION, encEnabled); // must be true : enabled bundle.putBoolean(SecureChannelManager.BUNDLE_EXTRA_SCP_MAC, macEnabled); // must be true : enabled bundle.putInt(SecureChannelManager.BUNDLE_EXTRA_SCP_KEY_PARAM_ECC, SecureChannelManager.BUNDLE_SCP_KEY_PARAM_ECC_NIST_P256); // ECC curve : NIST-P256 SecureChannelManager credentialUtil = SecureChannelManager.getInstance(); ApduMessage resp = credentialUtil.createSecureChannel(protocol, bundle); if(resp.status == SecureChannelManager.STATUS_FAILURE) { Log.e(TAG, "Channel construction failed"); return; } while (resp.messageType == SecureChannelManager.MESSAGE_TYPE_FORWARD_TO_SD) { Log.e(TAG, "FORWARDING : " + Hex.toHexString(resp.message)); // forward APDU to your SD byte[] sdResp = transmitData(resp.message); if(sdResp == null || sdResp.length < 2) { Log.e(TAG, "sdResp == null"); return; } resp = credentialUtil.processMessage(SecureChannelManager.MESSAGE_TYPE_SECURE_CHANNEL, sdResp); switch(resp.status) { case SecureChannelManager.STATUS_SUCCESS: if(resp.messageType == SecureChannelManager.MESSAGE_TYPE_FORWARD_TO_SD) continue; case SecureChannelManager.STATUS_SC_CONSTRUCTED: Log.e(TAG, "Channel constructed!"); break; default: mSecureChannelExists = false; Log.e(TAG, "Channel construction failed"); break; } } } catch (SecurityException e) { Log.w(TAG, "SecurityException: " + e); } |
API level 20 |
KNOX 2.7 |
API to destroy secure channel.
An application can use this API to destroy secure channel.
SecureChannelManager credManager = SecureChannelManager.getInstance(); try { int result = credManager.destroySecureChannel(); } catch (SecurityException e) { Log.w(TAG, "SecurityException: " + e); } |
API level 20 |
KNOX 2.7 |
Retrieve SecureChannelManager Instance which can interact with KNOX Credential Storage.
API level 20 |
KNOX 2.7 |
API to Process message via SCP11.
type | message type, MESSAGE_TYPE_COMMAND , MESSAGE_TYPE_RESPONSE , MESSAGE_TYPE_SECURE_CHANNEL |
---|---|
msg | input data |
An application can use this API to Process message via SCP11.
try { SecureChannelManager credentialUtil = SecureChannelManager.getInstance(); // Encrypt response resp = credentialUtil.processMessage(SecureChannelManager.MESSAGE_TYPE_COMMAND, data); if (resp.status != SecureChannelManager.STATUS_SUCCESS) { Log.e(TAG, "Command encryption failed"); } else { Log.e(TAG, "encrypted length : " + resp.message.length); } // forward APDU to your SD byte[] sdResp = transmitData(resp.message); // Decrypt response resp = credentialUtil.processMessage(SecureChannelManager.MESSAGE_TYPE_RESPONSE, data); if (resp == null || resp.status != SecureChannelManager.STATUS_SUCCESS) { Log.e(TAG, "Response decryption failed"); break; } else { Log.d(TAG,"decrypt success." + new String(resp.message)); } } catch (SecurityException e) { Log.w(TAG, "SecurityException: " + e); } |
API level 20 |
KNOX 2.7 |