src/wolfSSL/src/internal.c
static int NtruSecretEncrypt(QSHKey* key, byte* bufIn, word32 inSz,
        byte* bufOut, word16* outSz)
{
    int    ret;
    DRBG_HANDLE drbg;

    /* sanity checks on input arguments */
    if (key == NULL || bufIn == NULL || bufOut == NULL || outSz == NULL)
        return BAD_FUNC_ARG;

    if (key->pub.buffer == NULL)
        return BAD_FUNC_ARG;

    switch (key->name) {
        case WOLFSSL_NTRU_EESS439:
        case WOLFSSL_NTRU_EESS593:
        case WOLFSSL_NTRU_EESS743:
            break;
        default:
            WOLFSSL_MSG("Unknown QSH encryption key!");
            return -1;
    }

    /* set up ntru drbg */
    ret = ntru_crypto_drbg_external_instantiate(GetEntropy, &drbg);
    if (ret != DRBG_OK)
        return NTRU_DRBG_ERROR;

    /* encrypt the byte array */
    ret = ntru_crypto_ntru_encrypt(drbg, key->pub.length, key->pub.buffer,
        inSz, bufIn, outSz, bufOut);
    ntru_crypto_drbg_uninstantiate(drbg);
    if (ret != NTRU_OK)
        return NTRU_ENCRYPT_ERROR;

    return ret;
}
/* Encrypt a byte array using ntru
   key    a struct containing the public key to use
   bufIn  array to be encrypted
   inSz   size of bufIn array
   bufOut cipher text out
   outSz  will be set to the new size of cipher text
 */
Encrypt a byte array using ntru
key    a struct containing the public key to use
bufIn  array to be encrypted
inSz   size of bufIn array
bufOut cipher text out
outSz  will be set to the new size of cipher text
Encrypt a byte array using ntru key a struct containing the public key to use bufIn array to be encrypted inSz size of bufIn array bufOut cipher text out outSz will be set to the new size of cipher text
static int NtruSecretEncrypt(QSHKey* key, byte* bufIn, word32 inSz,
        byte* bufOut, word16* outSz)
{
    int    ret;
    DRBG_HANDLE drbg;
    if (key == NULL || bufIn == NULL || bufOut == NULL || outSz == NULL)
        return BAD_FUNC_ARG;
    if (key->pub.buffer == NULL)
        return BAD_FUNC_ARG;
    switch (key->name) {
        case WOLFSSL_NTRU_EESS439:
        case WOLFSSL_NTRU_EESS593:
        case WOLFSSL_NTRU_EESS743:
            break;
        default:
            WOLFSSL_MSG("Unknown QSH encryption key!");
            return -1;
    }
    ret = ntru_crypto_drbg_external_instantiate(GetEntropy, &drbg);
    if (ret != DRBG_OK)
        return NTRU_DRBG_ERROR;
    ret = ntru_crypto_ntru_encrypt(drbg, key->pub.length, key->pub.buffer,
        inSz, bufIn, outSz, bufOut);
    ntru_crypto_drbg_uninstantiate(drbg);
    if (ret != NTRU_OK)
        return NTRU_ENCRYPT_ERROR;
    return ret;
}
static int NtruSecretEncrypt ( QSHKey * key , byte * bufIn , word32 inSz , byte * bufOut , word16 * outSz ) { int ret ; DRBG_HANDLE drbg ; if ( key == NULL || bufIn == NULL || bufOut == NULL || outSz == NULL ) return BAD_FUNC_ARG ; if ( key -> pub . buffer == NULL ) return BAD_FUNC_ARG ; switch ( key -> name ) { case WOLFSSL_NTRU_EESS439 : case WOLFSSL_NTRU_EESS593 : case WOLFSSL_NTRU_EESS743 : break ; default : WOLFSSL_MSG ( " " ) ; return -1 ; } ret = ntru_crypto_drbg_external_instantiate ( GetEntropy , & drbg ) ; if ( ret != DRBG_OK ) return NTRU_DRBG_ERROR ; ret = ntru_crypto_ntru_encrypt ( drbg , key -> pub . length , key -> pub . buffer , inSz , bufIn , outSz , bufOut ) ; ntru_crypto_drbg_uninstantiate ( drbg ) ; if ( ret != NTRU_OK ) return NTRU_ENCRYPT_ERROR ; return ret ; }
Encrypt a byte array using ntru
key    a struct containing the public key to use
bufIn  array to be encrypted
inSz   size of bufIn array
bufOut cipher text out
outSz  will be set to the new size of cipher text
Encrypt a byte array using ntru key a struct containing the public key to use bufIn array to be encrypted inSz size of bufIn array bufOut cipher text out outSz will be set to the new size of cipher text
/* sanity checks on input arguments */ /* set up ntru drbg */ /* encrypt the byte array */