bool uc_import_ecc_pub_key(uc_ed25519_key *key, const unsigned char *in, size_t inlen) { if(inlen != ED25519_PUB_KEY_SIZE) return false; wc_ed25519_init(key); const int status = wc_ed25519_import_public(in, inlen, key); if(status < 0) { UCERROR("import ecc pub", status); return false; } UCDUMP("ECCPUB", key->p, ED25519_PUB_KEY_SIZE); return true; }
/* For importing a private key and its associated public key. */ int wc_ed25519_import_private_key(const byte* priv, word32 privSz, const byte* pub, word32 pubSz, ed25519_key* key) { int ret; /* sanity check on arguments */ if (priv == NULL || pub == NULL || key == NULL) return BAD_FUNC_ARG; /* key size check */ if (privSz < ED25519_KEY_SIZE || pubSz < ED25519_PUB_KEY_SIZE) return BAD_FUNC_ARG; /* import public key */ ret = wc_ed25519_import_public(pub, pubSz, key); if (ret != 0) return ret; /* make the private key (priv + pub) */ XMEMCPY(key->k, priv, ED25519_KEY_SIZE); XMEMCPY(key->k + ED25519_KEY_SIZE, key->p, ED25519_PUB_KEY_SIZE); return ret; }
int crypto_ed25519_import_public_key(ed25519_key *key, const byte *data, size_t size) { return wc_ed25519_import_public(data, size, key); }