int main()
{
    int32_t ret;
    
    printf("\nsize of long long %d.", sizeof(long long ));
    printf("\nsize of long %d.", sizeof(long ));

#if defined(DEBUG_WOLFSSL)
    wolfSSL_Debugging_ON();
#endif

    wolfCrypt_Init();

#if !defined(NO_BIG_INT)
    if (CheckCtcSettings() != 1)
        printf("\nBuild vs runtime math mismatch\n");

#ifdef USE_FAST_MATH
    if (CheckFastMathSettings() != 1)
        printf("\nBuild vs runtime fastmath FP_MAX_BITS mismatch\n");
#endif /* USE_FAST_MATH */
#endif /* !NO_BIG_INT */

    ret = rsa_test();

    printf("\nret %d", ret);

    return 0;
}
Example #2
0
int main(void)
{
	wolfCrypt_Init();

	printf("\nCrypt Test\n");
	wolfcrypt_test(&args);
	printf("Crypt Test: Return code %d\n", args.return_code);

	wolfCrypt_Cleanup();

	return 0;
}
Example #3
0
/* entry point */
void app_main(void)
{
#ifndef NO_CRYPT_BENCHMARK

/* when using atecc608a on esp32-wroom-32se */
#if defined(WOLFSSL_ESPWROOM32SE) && defined(HAVE_PK_CALLBACKS) \
                                  && defined(WOLFSSL_ATECC508A)
    #if defined(CUSTOM_SLOT_ALLOCATION)
    my_atmel_slotInit();
    /* to register the callback, it needs to be initialized. */
    if ((wolfCrypt_Init()) != 0) {
       ESP_LOGE(TAG, "wolfCrypt_Init failed");
       return;
    }
    atmel_set_slot_allocator(my_atmel_alloc, my_atmel_free);
    #endif
#endif
    wolf_benchmark_task();
#else
#endif /* NO_CRYPT_BENCHMARK */
}
Example #4
0
int main()
{
    int ret;

    wolfCrypt_Init();

    ret = wc_InitRng(&mRng);
    if (ret != 0) {
        printf("Init RNG failed %d\n", ret);
    }

    StackSizeCheck(NULL, do_it);
    printf("sizeof RNG = %lu\n", sizeof(WC_RNG));
    printf("sizeof ecc_key = %lu\n", sizeof(ecc_key));

    ret = wc_FreeRng(&mRng);
    if (ret != 0) {
        printf("Free RNG failed %d\n", ret);
    }
    wolfCrypt_Cleanup();

    return 0;
}
int main(int argc, char** argv)
{
    int ret, devId;
    int encryptedSz, decryptedSz;
    word32 certSz, keySz;
    myCryptoDevCtx myCtx;

    byte cert[2048];
    byte key[2048];
    byte encrypted[2048];
    byte decrypted[2048];
    
#ifdef DEBUG_WOLFSSL
    wolfSSL_Debugging_ON();
#endif

    ret = wolfCrypt_Init();
    if (ret != 0) {
        printf("wolfCrypt initialization failed\n");
        return -1;
    }

    /* example data for callback */
    myCtx.exampleVar = 1;

    /* setting devId to something other than INVALID_DEVID, enables
       cryptodev callback to be used internally by wolfCrypt */
    devId = 1;
    ret = wc_CryptoDev_RegisterDevice(devId, myCryptoDevCb, &myCtx);
    if (ret != 0) {
        printf("Failed to register crypto dev device, ret = %d\n", ret);
        return -1;
    }

    certSz = sizeof(cert);
    keySz = sizeof(key);
    ret = load_certs(cert, &certSz, key, &keySz);
    if (ret != 0)
        return -1;

    /* no attributes */
    encryptedSz = signedData_sign_noattrs(cert, certSz, key, keySz,
                                          encrypted, sizeof(encrypted), devId);
    if (encryptedSz < 0)
        return -1;

    decryptedSz = signedData_verify(encrypted, encryptedSz,
                                    cert, certSz, key, keySz,
                                    decrypted, sizeof(decrypted), devId);
    if (decryptedSz < 0)
        return -1;

    /* default attributes + messageType attribute */
    encryptedSz = signedData_sign_attrs(cert, certSz, key, keySz,
                                        encrypted, sizeof(encrypted), devId);
    if (encryptedSz < 0)
        return -1;

    decryptedSz = signedData_verify(encrypted, encryptedSz,
                                    cert, certSz, key, keySz,
                                    decrypted, sizeof(decrypted), devId);
    if (decryptedSz < 0)
        return -1;

    (void)argc;
    (void)argv;

    return 0;
}