FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/dh.c
/* Can be used with WOLFSSL_DH_EXTRA when key is loaded with 
    wc_DhKeyDecode or wc_DhImportKeyPair */
Can be used with WOLFSSL_DH_EXTRA when key is loaded with
wc_DhKeyDecode or wc_DhImportKeyPair
Can be used with WOLFSSL_DH_EXTRA when key is loaded with wc_DhKeyDecode or wc_DhImportKeyPair
int wc_DhExportKeyPair(DhKey* key, byte* priv, word32* pPrivSz, 
    byte* pub, word32* pPubSz)
{
    int ret = 0;
    word32 pubSz, privSz;
    if (key == NULL || (priv && pPrivSz == NULL) || (pub && pPubSz == NULL)) {
        return BAD_FUNC_ARG;
    }
    if (priv) {
        privSz = mp_unsigned_bin_size(&key->priv);
        if (privSz > *pPrivSz) {
            return BUFFER_E;
        }
        *pPrivSz = privSz;
        ret |= mp_to_unsigned_bin(&key->priv, priv);
    }
    if (pub) {
        pubSz = mp_unsigned_bin_size(&key->pub);
        if (pubSz > *pPubSz) {
            return BUFFER_E;
        }
        *pPubSz = pubSz;
        ret |= mp_to_unsigned_bin(&key->pub,  pub);
    }
    if (ret != 0)
        ret = ASN_DH_KEY_E;
    return ret;
}
int wc_DhExportKeyPair ( DhKey * key , byte * priv , word32 * pPrivSz , byte * pub , word32 * pPubSz ) { int ret = 0 ; word32 pubSz , privSz ; if ( key == NULL || ( priv && pPrivSz == NULL ) || ( pub && pPubSz == NULL ) ) { return BAD_FUNC_ARG ; } if ( priv ) { privSz = mp_unsigned_bin_size ( & key -> priv ) ; if ( privSz > * pPrivSz ) { return BUFFER_E ; } * pPrivSz = privSz ; ret |= mp_to_unsigned_bin ( & key -> priv , priv ) ; } if ( pub ) { pubSz = mp_unsigned_bin_size ( & key -> pub ) ; if ( pubSz > * pPubSz ) { return BUFFER_E ; } * pPubSz = pubSz ; ret |= mp_to_unsigned_bin ( & key -> pub , pub ) ; } if ( ret != 0 ) ret = ASN_DH_KEY_E ; return ret ; }
Can be used with WOLFSSL_DH_EXTRA when key is loaded with
wc_DhKeyDecode or wc_DhImportKeyPair
Can be used with WOLFSSL_DH_EXTRA when key is loaded with wc_DhKeyDecode or wc_DhImportKeyPair