src/wolfSSL/src/internal.c
static int NtruSecretDecrypt(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->pri.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 decryption key!");
            return -1;
    }


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

    /* decrypt cipher text */
    ret = ntru_crypto_ntru_decrypt(key->pri.length, key->pri.buffer,
        inSz, bufIn, outSz, bufOut);
    ntru_crypto_drbg_uninstantiate(drbg);
    if (ret != NTRU_OK)
        return NTRU_ENCRYPT_ERROR;

    return ret;
}
/* Decrypt a byte array using ntru
   key    a struct containing the private key to use
   bufIn  array to be decrypted
   inSz   size of bufIn array
   bufOut plain text out
   outSz  will be set to the new size of plain text
 */
Decrypt a byte array using ntru
key    a struct containing the private key to use
bufIn  array to be decrypted
inSz   size of bufIn array
bufOut plain text out
outSz  will be set to the new size of plain text
Decrypt a byte array using ntru key a struct containing the private key to use bufIn array to be decrypted inSz size of bufIn array bufOut plain text out outSz will be set to the new size of plain text
static int NtruSecretDecrypt(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->pri.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 decryption key!");
            return -1;
    }
    ret = ntru_crypto_drbg_external_instantiate(GetEntropy, &drbg);
    if (ret != DRBG_OK)
        return NTRU_DRBG_ERROR;
    ret = ntru_crypto_ntru_decrypt(key->pri.length, key->pri.buffer,
        inSz, bufIn, outSz, bufOut);
    ntru_crypto_drbg_uninstantiate(drbg);
    if (ret != NTRU_OK)
        return NTRU_ENCRYPT_ERROR;
    return ret;
}
static int NtruSecretDecrypt ( 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 -> pri . 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_decrypt ( key -> pri . length , key -> pri . buffer , inSz , bufIn , outSz , bufOut ) ; ntru_crypto_drbg_uninstantiate ( drbg ) ; if ( ret != NTRU_OK ) return NTRU_ENCRYPT_ERROR ; return ret ; }
Decrypt a byte array using ntru
key    a struct containing the private key to use
bufIn  array to be decrypted
inSz   size of bufIn array
bufOut plain text out
outSz  will be set to the new size of plain text
Decrypt a byte array using ntru key a struct containing the private key to use bufIn array to be decrypted inSz size of bufIn array bufOut plain text out outSz will be set to the new size of plain text
/* sanity checks on input arguments */ /* set up drbg */ /* decrypt cipher text */