|
opensc
NPCI secure-component & UPI Lite / Lite X wallet reimplementation
|
Single-file reimplementation of libSecureComponent.so (NPCI's Common Library). More...
#include <jni.h>#include <openssl/evp.h>#include <openssl/rsa.h>#include <openssl/ec.h>#include <openssl/x509.h>#include <openssl/crypto.h>#include <pthread.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>
Data Structures | |
| struct | AliasKeys |
| A keystore entry: one alias with its lazily-generated RSA and EC keypairs. More... | |
Functions | |
| static AliasKeys * | store_get_or_create (const char *alias) |
Finds, or lazily creates, the RSA+EC keypairs for alias (thread-safe). | |
| static uint8_t * | utf16_to_utf8 (JNIEnv *env, jstring s, size_t *out_len) |
| Converts a Java String to real UTF-8 bytes (JNI's GetStringUTFChars gives modified UTF-8). | |
| static int | b64_val (uint8_t c) |
| Maps a base64 character to its 6-bit value, or -1 if not a base64 digit. | |
| static uint8_t * | b64_decode (const char *in, size_t in_len, size_t *out_len) |
| Decodes base64 like android.util.Base64 NO_WRAP: standard alphabet, padding optional. | |
| static uint8_t * | rsa_pss_sign (EVP_PKEY *key, const uint8_t *msg, size_t msg_len, size_t *sig_len) |
| Signs with RSASSA-PSS/SHA-512 (MGF1-SHA-512, saltLen=digest) — the CL's "SHA512withRSA/PSS". | |
| static uint8_t * | ecdsa_sign (EVP_PKEY *key, const uint8_t *msg, size_t msg_len, size_t *sig_len) |
| Signs with ECDSA-SHA256 (DER) — the CL's useEc path. | |
| static int | ecdsa_verify (EVP_PKEY *key, const uint8_t *msg, size_t msg_len, const uint8_t *sig, size_t sig_len) |
Verifies an ECDSA-SHA256 signature over msg; returns 1 if valid, else 0. | |
| static jbyteArray JNICALL | native_sign (JNIEnv *env, jclass clazz, jstring jdata, jstring jalias, jboolean useEc) |
JNI nOfflineSignWithKey: signs jdata under jalias (RSA-PSS, or ECDSA when useEc). | |
| static jboolean JNICALL | native_verify (JNIEnv *env, jclass clazz, jstring jdata, jstring jsigB64, jobject pubKeyObj) |
JNI nOfflineVerifyEcSignature: verifies an ECDSA-SHA256 signature of jdata under pubKeyObj. | |
| static void JNICALL | native_enable (JNIEnv *env, jclass clazz) |
| JNI nEnableUPILITEX: second-stage registration of the two signing natives. | |
| JNIEXPORT jint JNICALL | JNI_OnLoad (JavaVM *vm, void *reserved) |
| JNI entry point: registers nEnableUPILITEX, matching the genuine .so's two-stage registration. | |
Variables | |
| static AliasKeys * | g_store = NULL |
| Head of the in-memory alias store. | |
| static pthread_mutex_t | g_store_lock = PTHREAD_MUTEX_INITIALIZER |
| Guards g_store. | |
Single-file reimplementation of libSecureComponent.so (NPCI's Common Library).
Build modes (JNI shared lib / self-test / stdio server) are documented in HACKING.md.