commit 194e79eaa0b5b534a2cad45c35102e11c17ea6a4 parent 7dfd3531d2ee0fcd37d0fe1674ca0b3f8acb0093 Author: Cedric <cedric.zwahlen@students.bfh.ch> Date: Sun, 19 Nov 2023 23:55:58 +0100 Add auxiliary program This program writes messages and corresponding signatues, as well as a public key into files, which can be read by the main program. Diffstat:
15 files changed, 574 insertions(+), 909 deletions(-)
diff --git a/.DS_Store b/.DS_Store Binary files differ. diff --git a/source/opencl-test.h b/source/opencl-test.h @@ -16,7 +16,12 @@ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> + +#if __APPLE__ +#include <OpenCL/opencl.h> +#elif #include <CL/opencl.h> +#endif #include "big-int-test.h" diff --git a/source/rsa-test.c b/source/rsa-test.c @@ -10,7 +10,11 @@ #include "openssl-test.h" +#if __APPLE__ +#include <OpenCL/opencl.h> +#elif #include <CL/opencl.h> +#endif #include "ctype.h" #include "time.h" @@ -42,15 +46,15 @@ void setup_gcry(void) { } -void generate_random_pairs(DIGIT_T *bases, size_t *b_len, - DIGIT_T *exponents, size_t *e_len, - DIGIT_T *moduli, size_t *m_len, - DIGIT_T *signatures, size_t *s_len, +void generate_random_pairs(DIGIT_T *bases, unsigned long *b_len, + DIGIT_T *exponents, unsigned long *e_len, + DIGIT_T *moduli, unsigned long *m_len, + DIGIT_T *signatures, unsigned long *s_len, const unsigned int n) { int i; - int sz = 2048 / sizeof(char); + int sz = 2048; for (i = 0; i < n; i++) { @@ -145,10 +149,10 @@ void generate_random_pairs(DIGIT_T *bases, size_t *b_len, } -int verify_with_opencl(DIGIT_T *bases, size_t *b_len, - DIGIT_T *exponents, size_t *e_len, - DIGIT_T *moduli, size_t *m_len, - DIGIT_T *signatures, size_t *s_len, +int verify_with_opencl(DIGIT_T *bases, unsigned long *b_len, + DIGIT_T *exponents, unsigned long *e_len, + DIGIT_T *moduli, unsigned long *m_len, + DIGIT_T *signatures, unsigned long *s_len, const unsigned int n) { int err; // error code returned from api calls @@ -209,7 +213,7 @@ int verify_with_opencl(DIGIT_T *bases, size_t *b_len, // Connect to a compute device // - int gpu = 1; + //int gpu = 1; err = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_ALL, 1, &device_id, NULL); // gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL); @@ -433,6 +437,8 @@ int verify_with_opencl(DIGIT_T *bases, size_t *b_len, clReleaseCommandQueue(commands); clReleaseContext(context); + return 0; + } int rsa_tests(void) { @@ -446,598 +452,34 @@ int rsa_tests(void) { DIGIT_T *s = malloc(32768); DIGIT_T *t = malloc(32768); - size_t *u = malloc(gen_n_pairs * sizeof(size_t)); - size_t *v = malloc(gen_n_pairs * sizeof(size_t)); - size_t *w = malloc(gen_n_pairs * sizeof(size_t)); - size_t *x = malloc(gen_n_pairs * sizeof(size_t)); + size_t *u = malloc(gen_n_pairs * sizeof(unsigned long)); + size_t *v = malloc(gen_n_pairs * sizeof(unsigned long)); + size_t *w = malloc(gen_n_pairs * sizeof(unsigned long)); + size_t *x = malloc(gen_n_pairs * sizeof(unsigned long)); generate_random_pairs(q, u, r, v, s, w, t, x, gen_n_pairs); - + struct timespec t1, t2; + + clock_gettime(CLOCK_REALTIME, &t1); verify_with_opencl(q, u, r, v, s, w, t, x, gen_n_pairs); - - - - - - printf("____\n"); - - - - - DIGIT_T *y = malloc(2048); - - DIGIT_T *s_window = &s[0]; - DIGIT_T *r_window = &r[0]; - DIGIT_T *t_window = &t[0]; - - mpModExpO(y, t_window, r_window, s_window, x[0], v[0]); - - size_t sz_y = x[0]; - - char comp[sz_y]; - - mpConvToHex(y, sz_y, comp, sz_y); - - printf("%s",comp); - - - char *template = "(genkey(rsa(nbits 4:2048)))"; - gcry_sexp_t parms; - - gcry_sexp_new(&parms, template, strlen(template), 1); - - // contains key material - gcry_sexp_t key; - - gcry_pk_genkey(&key,parms); - - // show_sexp("\n", key); - - // create a large number, we want to encrypt it - - - char *val = "1234567890ABCDEFFEDCBA0987654321"; - gcry_mpi_t mpi = gcry_mpi_new((int)strlen(val) * 8); - size_t scanned = 0; - - gcry_mpi_scan(&mpi, GCRYMPI_FMT_HEX, val, 0, &scanned); - - gcry_sexp_t toSign; - size_t errOff = 0; - char *dataformat = "(data (flags raw) (value %m))"; - - gcry_sexp_build(&toSign,&errOff,dataformat,mpi); - - // show_sexp("\n", toSign); - - // MARK: RSA verification - - // use gcry_rsa_sign – without padding? - gcry_sexp_t resSign; - - gcry_pk_sign(&resSign, toSign, key); - - // measure time - - // do the same thing with our bigNum library – do we even get the same signature? - - // these must be freed manually - gcry_mpi_t n_mpi; - gcry_mpi_t e_mpi; - gcry_mpi_t d_mpi; - - gcry_sexp_extract_param(key,NULL,"n e",&n_mpi, &e_mpi, NULL); - - gcry_mpi_t sig_mpi; - - gcry_sexp_extract_param(resSign,NULL,"s",&sig_mpi, NULL); - - - // may be a lot shorter – these will contain the numbers in HEX string form – for use in my bigNum - unsigned char *n = malloc(2048); - unsigned char *e = malloc(2048); - //unsigned char *d = malloc(2048); - size_t nL = 0; - - // check returns - gcry_mpi_print(GCRYMPI_FMT_HEX,n,2048,&nL,n_mpi); - gcry_mpi_print(GCRYMPI_FMT_HEX,e,2048,&nL,e_mpi); - // gcry_mpi_print(GCRYMPI_FMT_HEX,d,2048,&nL,d_mpi); - - unsigned char *sgn = malloc(2048); - gcry_mpi_print(GCRYMPI_FMT_HEX,sgn,2048,&nL,sig_mpi); - - - - // openssl test - -// test(e, d, n); - struct timespec t1, t2; - - clock_t start, end; - double cpu_time_used; - - start = clock(); - - // main_mmul(); - - end = clock(); - cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC; - - printf("\nSign montgomery (my algorithm): %f seconds\n", cpu_time_used); - - - - clock_gettime(CLOCK_REALTIME, &t1); - - if (verify(sgn, e, n, val)) { - - printf("\nverification failed\n"); - - } else { - - printf("\nverification successful\n"); - - } - clock_gettime(CLOCK_REALTIME, &t2); - float seconds_1 = (t2.tv_nsec - t1.tv_nsec) / 1000; - - printf("\nSign 1 (my algorithm): %f micro seconds\n", seconds_1); - - - clock_gettime(CLOCK_REALTIME, &t1); - // maybe we want to do more here - if (gcry_pk_verify(resSign, toSign, key)) { - - printf("\nverification failed\n"); - - } else { - - printf("\nverification successful\n"); - - } - - clock_gettime(CLOCK_REALTIME, &t2); - float seconds_0 = (t2.tv_nsec - t1.tv_nsec) / 1000; - printf("\nSign 0 (gcrpypt): %f micro seconds\n", seconds_0); - - // try to put it onto the gpu - - // MARK: GPU Code - - int err; // error code returned from api calls - - // number of correct results returned - - size_t global; // global domain size for our calculation - size_t local; // local domain size for our calculation - - cl_device_id device_id; // compute device id - cl_context context; // compute context - cl_command_queue commands; // compute command queue - cl_program program; // compute program - cl_kernel kernel; // compute kernel - - //cl_mem input; // device memory used for the input array - //cl_mem output; // device memory used for the output array - - cl_uint max_platforms = 4; - cl_platform_id platforms[max_platforms]; - cl_uint num_platforms; - cl_int rplat; - - rplat = clGetPlatformIDs (max_platforms, platforms, &num_platforms); - if (rplat != CL_SUCCESS) - { - printf("Error: Failed to lookup platforms! (%d)\n", rplat); - return EXIT_FAILURE; - } - printf("Found %u platforms\n", (unsigned int) num_platforms); - if (0 == num_platforms) - { - return EXIT_FAILURE; - } - // Connect to a compute device - // - int gpu = 1; - err = clGetDeviceIDs(platforms[0], - gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL); - if (err != CL_SUCCESS) - { - printf("Error: Failed to create a device group!\n"); - return EXIT_FAILURE; - } - - size_t retSize_1 = 0; - clGetDeviceInfo(device_id, CL_DRIVER_VERSION, 0, NULL, &retSize_1); - char driver_version[retSize_1]; - clGetDeviceInfo(device_id, CL_DRIVER_VERSION, retSize_1, &driver_version, &retSize_1); - - //printf("driver version: %s\n", driver_version); - - - size_t retSize_2 = sizeof(cl_uint); - cl_uint address_bits = 0; - clGetDeviceInfo(device_id, CL_DEVICE_ADDRESS_BITS, 0, NULL, &retSize_2); - clGetDeviceInfo(device_id, CL_DEVICE_ADDRESS_BITS, retSize_2, &address_bits, &retSize_2); - - //printf("device address bits: %i\n", address_bits); - - - // Create a compute context - // - context = clCreateContext(0, 1, &device_id, NULL, NULL, &err); - if (!context) - { - printf("Error: Failed to create a compute context!\n"); - return EXIT_FAILURE; - } - - // Create a command commands - // - commands = clCreateCommandQueue(context, device_id, 0, &err); - if (!commands) - { - printf("Error: Failed to create a command commands!\n"); - return EXIT_FAILURE; - } - - // get the kernel from a file instead of a constant - - - FILE *fp = fopen("./verify.cl", "r"); - fseek(fp, 0L, SEEK_END); - size_t sz = ftell(fp); - rewind(fp); - - char *kernelBuf = malloc(sz); - fread(kernelBuf, sizeof(char), sz, fp); - fclose(fp); - - // Create the compute program from the source buffer - // - //program = clCreateProgramWithSource(context, 1, (const char **) & KernelSource, NULL, &err); - program = clCreateProgramWithSource(context, 1, (const char **) & kernelBuf, &sz, &err); - if (!program) - { - printf("Error: Failed to create compute program!\n"); - return EXIT_FAILURE; - } - - // Build the program executable - // - err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL); - if (err != CL_SUCCESS) - { - size_t len; - char buffer[2048]; - - printf("Error: Failed to build program executable!\n"); - clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len); - printf("%s\n", buffer); - exit(1); - } - - // Create the compute kernel in the program we wish to run - // - kernel = clCreateKernel(program, "several", &err); - if (!kernel || err != CL_SUCCESS) - { - printf("Error: Failed to create compute kernel!\n"); - exit(1); - } - - // Create the input and output arrays in device memory for our calculation - // - //input = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(float) * count, NULL, NULL); - //output = clCreateBuffer(context, CL_MEM_WRITE_ONLY, sizeof(float) * count, NULL, NULL); - - cl_mem s_mem; - cl_mem e_mem; - cl_mem n_mem; - - cl_mem res_mem; - cl_mem valid; // needs to be a buffer because it goes out - - int8_t signature_is_valid = 0; - - DIGIT_T n_buf [MAX_ALLOC_SIZE*2]; - DIGIT_T e_buf [MAX_ALLOC_SIZE*2]; - DIGIT_T s_buf [MAX_ALLOC_SIZE*2]; - - DIGIT_T res_buf [MAX_ALLOC_SIZE*2]; - - mpSetZero(n_buf, MAX_ALLOC_SIZE*2); - mpSetZero(e_buf, MAX_ALLOC_SIZE*2); - mpSetZero(s_buf, MAX_ALLOC_SIZE*2); - - mpSetZero(res_buf, MAX_ALLOC_SIZE*2); - - mpConvFromHex(n_buf, strlen(n), n); - mpConvFromHex(e_buf, strlen(e), e); - mpConvFromHex(s_buf, strlen(sgn), sgn); - - mpConvFromHex(res_buf, strlen(val), val); - - size_t sz_n = mpSizeof(n_buf, MAX_ALLOC_SIZE*2); - size_t sz_s = mpSizeof(s_buf, MAX_ALLOC_SIZE*2); - - - unsigned long s_len = mpSizeof(s_buf, MAX_ALLOC_SIZE*2); - unsigned long e_len = mpSizeof(e_buf, MAX_ALLOC_SIZE*2); - unsigned long n_len = mpSizeof(n_buf, MAX_ALLOC_SIZE*2); - - unsigned long res_len = mpSizeof(res_buf, MAX_ALLOC_SIZE*2); - - unsigned long max_len = max(sz_s,sz_n); - - n_mem = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(DIGIT_T) * n_len, NULL, NULL); - e_mem = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(DIGIT_T) * e_len, NULL, NULL); - s_mem = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(DIGIT_T) * s_len, NULL, NULL); - - res_mem = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(DIGIT_T) * res_len, NULL, NULL); - valid = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int8_t) ,NULL, NULL); - - - global = 4096; - //local = global; - - - if (!s_mem || !e_mem || !n_mem || !res_mem || !valid ) - { - printf("Error: Failed to allocate device memory!\n"); - exit(1); - } - - - // Write our data set into the input array in device memory - // - err = clEnqueueWriteBuffer(commands, s_mem, CL_TRUE, 0, s_len * sizeof(DIGIT_T), s_buf, 0, NULL, NULL); - err |= clEnqueueWriteBuffer(commands, e_mem, CL_TRUE, 0, e_len * sizeof(DIGIT_T), e_buf, 0, NULL, NULL); - err |= clEnqueueWriteBuffer(commands, n_mem, CL_TRUE, 0, n_len * sizeof(DIGIT_T), n_buf, 0, NULL, NULL); - err |= clEnqueueWriteBuffer(commands, res_mem, CL_TRUE, 0, res_len * sizeof(DIGIT_T), res_buf, 0, NULL, NULL); - err |= clEnqueueWriteBuffer(commands, valid, CL_TRUE, 0, sizeof(int8_t), &signature_is_valid, 0, NULL, NULL); - if (err != CL_SUCCESS) - { - printf("Error: Failed to write to source array!\n"); - exit(1); - } - - // Set the arguments to our compute kernel - // FIXME: this is for some different version of the compute kernel, - // arguments do not match current compute kernel. Aborting... - abort (); - err = 0; - { - unsigned int ctr = 0; - - #define SET_ARG(var) \ - do { \ - int err = clSetKernelArg(kernel, ctr, sizeof(var), &var); \ - if (CL_SUCCESS != err) \ - { \ - printf("Error: Failed to set kernel argument %u! (%d)\n", ctr, err); \ - exit(1); \ - } \ - ctr++; \ - } while (0) - SET_ARG (s_mem); - SET_ARG (s_len); /* FIXME: treated as an array of size_t! */ - SET_ARG (e_mem); - SET_ARG (e_len); - SET_ARG (n_mem); - SET_ARG (n_len); - SET_ARG (res_mem); - SET_ARG (res_len); - SET_ARG (max_len); - SET_ARG (valid); - #undef SET_ARG - } -#if 0 - err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &s_mem); - err |= clSetKernelArg(kernel, 1, sizeof(unsigned int), &s_len); - err |= clSetKernelArg(kernel, 2, sizeof(cl_mem), &e_mem); - err |= clSetKernelArg(kernel, 3, sizeof(unsigned int), &e_len); - err |= clSetKernelArg(kernel, 4, sizeof(cl_mem), &n_mem); - err |= clSetKernelArg(kernel, 5, sizeof(unsigned int), &n_len); - err |= clSetKernelArg(kernel, 6, sizeof(cl_mem), &res_mem); - err |= clSetKernelArg(kernel, 7, sizeof(unsigned int), &res_len); - err |= clSetKernelArg(kernel, 8, sizeof(unsigned int), &max_len); - err |= clSetKernelArg(kernel, 9, sizeof(cl_mem), &valid); -#endif - //err |= clSetKernelArg(kernel, 2, sizeof(unsigned int), &count); - if (err != CL_SUCCESS) - { - printf("C2: Error: Failed to set kernel arguments! %d\n", err); - exit(1); - } - - // Get the maximum work group size for executing the kernel on the device - // - err = clGetKernelWorkGroupInfo(kernel, device_id, CL_KERNEL_WORK_GROUP_SIZE, sizeof(local), &local, NULL); - if (err != CL_SUCCESS) - { - printf("Error: Failed to retrieve kernel work group info! %d\n", err); - exit(1); - } - - - - - // Execute the kernel over the entire range of our 1d input data set - // using the maximum number of work group items for this device - // - - err = clEnqueueNDRangeKernel(commands, kernel, 1, NULL, &global, &local, 0, NULL, NULL); - if (err) - { - printf("Error: Failed to execute kernel!\n"); - return EXIT_FAILURE; - } - - struct timespec t3, t4; - - clock_gettime(CLOCK_REALTIME, &t3); - - // Wait for the command commands to get serviced before reading back results - // - clFinish(commands); - - clock_gettime(CLOCK_REALTIME, &t4); - - float seconds_2 = (t3.tv_nsec - t4.tv_nsec) / 1000; - - printf("\nGPU verification: %f micro seconds\n", seconds_2); - - - // Read back the results from the device to verify the output - // - //err = clEnqueueReadBuffer( commands, res_mem, CL_TRUE, 0, res_len, res_buf, 0, NULL, NULL ); - err = clEnqueueReadBuffer( commands, valid, CL_TRUE, 0, sizeof(int8_t), &signature_is_valid, 0, NULL, NULL ); - if (err != CL_SUCCESS) - { - printf("Error: Failed to read output array! %d\n", err); - exit(1); - } - - - printf("%i\n",signature_is_valid); - - // Print a brief summary detailing the results - - // Shutdown and cleanup - // - clReleaseMemObject(res_mem); - clReleaseMemObject(e_mem); - clReleaseMemObject(n_mem); - clReleaseMemObject(s_mem); - - clReleaseProgram(program); - clReleaseKernel(kernel); - clReleaseCommandQueue(commands); - clReleaseContext(context); + printf("\nGPU verification: %ld ms\n", (t2.tv_nsec - t1.tv_nsec) / 1000000); + + return 0; } -/* -//void bigNum_tests(void) { -void bigNum_tests(unsigned char* nn,unsigned char* ee,unsigned char* dd) { - - - // MARK: BIG NUM TESTs - - DIGIT_T N [MAX_ALLOC_SIZE*2]; - DIGIT_T e [MAX_ALLOC_SIZE*2]; - DIGIT_T d [MAX_ALLOC_SIZE*2]; - - DIGIT_T res [MAX_ALLOC_SIZE*2]; - - mpSetZero(N, MAX_ALLOC_SIZE*2); - mpSetZero(e, MAX_ALLOC_SIZE*2); - mpSetZero(d, MAX_ALLOC_SIZE*2); - - mpSetZero(res, MAX_ALLOC_SIZE*2); - - mpConvFromHex(N, strlen(nn), nn); - mpConvFromHex(e, strlen(ee), ee); - mpConvFromHex(d, strlen(dd), dd); - - size_t sz_n = mpSizeof(N, MAX_ALLOC_SIZE*2); - size_t sz_d = mpSizeof(d, MAX_ALLOC_SIZE*2); - - //mpModMult(res, e, d, N, max(sz_d,sz_n)); // that works :) - - mpModExpO(res, e, d, N, max(sz_d,sz_n)); - - size_t sz_res = mpSizeof(res, MAX_ALLOC_SIZE*2); - - char* pref = "\nHEX:\n"; - char* suf = "\n"; - // mpPrintHex(pref, res, sz_res, suf); - - - -} -*/ -int verify(unsigned char* sign, unsigned char* ee, unsigned char* nn, unsigned char* mm) { - - - DIGIT_T N [MAX_ALLOC_SIZE*2]; - DIGIT_T e [MAX_ALLOC_SIZE*2]; - DIGIT_T s [MAX_ALLOC_SIZE*2]; - - DIGIT_T res [MAX_ALLOC_SIZE*2]; - - mpSetZero(N, MAX_ALLOC_SIZE*2); - mpSetZero(e, MAX_ALLOC_SIZE*2); - mpSetZero(s, MAX_ALLOC_SIZE*2); - - mpSetZero(res, MAX_ALLOC_SIZE*2); - - mpConvFromHex(N, strlen(nn), nn); - mpConvFromHex(e, strlen(ee), ee); - mpConvFromHex(s, strlen(sign), sign); - - size_t sz_n = mpSizeof(N, MAX_ALLOC_SIZE*2); - size_t sz_s = mpSizeof(s, MAX_ALLOC_SIZE*2); - - //mpModMult(res, e, d, N, max(sz_d,sz_n)); // that works :) - - mpModExpO(res, s, e, N, max(sz_s,sz_n), mpSizeof(e, MAX_ALLOC_SIZE*2)); - - size_t sz_res = mpSizeof(res, MAX_ALLOC_SIZE*2); - - int sz_mm = strlen(mm) + 2; - - unsigned char comp[sz_mm]; - - mpConvToHex(res, sz_res, comp, sz_mm); - - upper(comp); - - return strcmp(comp, mm); -} -/* -int verify_gmp(unsigned char* base, unsigned char* exponent, unsigned char* modulus, unsigned char* comp) { - - - mpz_t b; - mpz_init_set_str(b,base,16); - - mpz_t e; - mpz_init_set_str(e,exponent,16); - - mpz_t m; - mpz_init_set_str(m,modulus,16); - - mpz_t c; - mpz_init_set_str(c,comp,16); - - mpz_t res; - mpz_init(res); - - mpz_powm(res, b, e, m); - - char *str; - str = mpz_get_str ((char *) 0, 16, res); - - - return 0; - -} -*/ static void show_sexp(const char *prefix, gcry_sexp_t a) { char *buf; size_t size; @@ -1051,11 +493,3 @@ static void show_sexp(const char *prefix, gcry_sexp_t a) { fprintf(stderr, "%.*s", (int) size, buf); gcry_free(buf); } - -static void upper(unsigned char* str) { - - for(int i = 0; str[i]; i++){ - str[i] = toupper(str[i]); - } - -} diff --git a/xcode/.DS_Store b/xcode/.DS_Store Binary files differ. diff --git a/xcode/lib-gpu-generate/lib-gpu-generate.entitlements b/xcode/lib-gpu-generate/lib-gpu-generate.entitlements @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict/> +</plist> diff --git a/xcode/lib-gpu-generate/main.c b/xcode/lib-gpu-generate/main.c @@ -0,0 +1,148 @@ +// +// main.c +// lib-gpu-generate +// +// Created by Cedric Zwahlen on 19.11.2023. +// + +#include <stdio.h> +#include <gcrypt.h> + +#define NEED_LIBGCRYPT_VERSION "1.10.1" + +void setup_gcry(void) { + + + /* Version check should be the very first call because it + makes sure that important subsystems are initialized. + #define NEED_LIBGCRYPT_VERSION to the minimum required version. */ + if (!gcry_check_version (NEED_LIBGCRYPT_VERSION)) + { + fprintf (stderr, "libgcrypt is too old (need %s, have %s)\n", + NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL)); + exit (2); } + /* Disable secure memory. */ + gcry_control (GCRYCTL_DISABLE_SECMEM, 0); + /* ... If required, other initialization goes here. */ + /* Tell Libgcrypt that initialization has completed. */ + gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); + +} + +int main(int argc, const char * argv[]) { + + // the first argument says how many signatures we should create, if there is no argument, let's say we make.. 4? + + int n = 0; + + // no arg + if (argc == 1) { + + n = 4; + + // a number is expected + } else if (argc == 2) { + + n = atoi(argv[1]); + + } + + if (n == 0) { + + printf("invalid parameters"); + abort(); + + } + + printf("generating %i signatures with the same key.\n",n); + + setup_gcry(); + + // make a key + char *template = "(genkey(rsa(nbits 4:2048)))"; + gcry_sexp_t parms; + + gcry_sexp_new(&parms, template, strlen(template), 1); + + gcry_sexp_t key; + + gcry_pk_genkey(&key,parms); + + FILE *pkfile; + FILE *msfile; + + pkfile = fopen("publickey.txt", "w"); + msfile = fopen("msgsig.txt", "w"); + + gcry_mpi_t n_mpi; + gcry_mpi_t e_mpi; + + gcry_sexp_extract_param(key,NULL,"n e",&n_mpi, &e_mpi, NULL); + + // e & n contain information about the public key, needed to verify the signatues later + + size_t n_len = 0; + size_t e_len = 0; + + // that is a bit much + unsigned char nn[2048]; + unsigned char ee[2048]; + + gcry_mpi_print(GCRYMPI_FMT_HEX,nn,2048,&n_len,n_mpi); + gcry_mpi_print(GCRYMPI_FMT_HEX,ee,2048,&e_len,e_mpi); + + fprintf(pkfile, "%s\n",nn); + fprintf(pkfile, "%s\n",ee); + + gcry_mpi_release(n_mpi); + gcry_mpi_release(e_mpi); + + fclose(pkfile); + + int i; + for (i = 0; i < n; i++) { + + int len = 8; + + gcry_mpi_t m_mpi = gcry_mpi_new(len * 8); // *8 because its bits not bytes + + gcry_mpi_randomize(m_mpi, len * 8, GCRY_STRONG_RANDOM); + + gcry_sexp_t toSign; + size_t errOff = 0; + char *dataformat = "(data (flags raw) (value %m))"; + + gcry_sexp_build(&toSign,&errOff,dataformat,m_mpi); + + gcry_sexp_t resSign; + + gcry_pk_sign(&resSign, toSign, key); + + gcry_mpi_t s_mpi; + + gcry_sexp_extract_param(resSign,NULL,"s",&s_mpi, NULL); + + // m_mpi contains the message, and s_mpi it's signature + + size_t m_len = 0; + size_t s_len = 0; + + // that is a bit much + unsigned char mm[2048]; + unsigned char ss[2048]; + + gcry_mpi_print(GCRYMPI_FMT_HEX,mm,2048,&m_len,m_mpi); + gcry_mpi_print(GCRYMPI_FMT_HEX,ss,2048,&s_len,s_mpi); + + fprintf(msfile, "%s:",mm); + fprintf(msfile, "%s\n",ss); + + gcry_mpi_release(s_mpi); + gcry_mpi_release(m_mpi); + } + + fclose(msfile); + + + return 0; +} diff --git a/xcode/lib-gpu-generate/msgsig.txt b/xcode/lib-gpu-generate/msgsig.txt @@ -0,0 +1,16 @@ +436FB24308EF665D:7AE29746A8D2E8F7BD0A46CE41A3B6EC41FEBBACD631222E3FBF8BD0581AB405F193425670EF88CFD55159812F328F10712788A4112F5142F07E58732005E33ABED94B52B26E196D430E32AE250A283BD9ECA07CE111B872C25EA9763A8FB6F5CBC8C1B035A2762CDC86FCC57EE335CD23B5D32D78175C0C897743E501F487001E086AE3C9B04FCB2C88356D24067C609A999A08FAE659D801A3366ED27D84C2824533378552CD85225C94B1325818A4ABF983D97A3684C2440BFAFDE209100B48589C3467B45DC282984774E2747D96DE5298623B6596B9030BF35CE3096A74FA725DD4053EA341381F9D0EBB5D74D0830D70F72C277069606E83724A725B41 +00FF2397B8AA99F05D:00B7B531089B254E648B1D22FF42DE5405FCFA93C54790D4B8D6D3EECAFA101A7F8AB72FED1C782A6B51B13DBB489976F26350897ACE99D94B0C671E506ACED56C9D39D21DFDAB9ECD5B65082353536FA167935ED4ACF434E98C4A7C49DA34C518BA74C41CF75FACC4C21435B4A40507FA22968628EB579E7593828FB55279DC0046A56AC27CD768DDE481D6E79C865F13E6D6425012F361964C718E357B28911613633624D15493999C25F0D47860007BAC89403D1251008216DB03AEABFC84A844329F7E14D2BFB835A3324C2A622E4CA08AA7C1E69C17EA7F4931572A0AF1506CA255A5B02BAC03F6A64EC94FFB0B2F9AF3B3A81B349501B1474B2A4D8A0352 +5F18CF0FE3D498B6:6CE98C13C69D3084A4A5C157FD7E55E7DFC5295B95F46E8DD58B02470D6CF190F6D54298EFDC9CCDCC35C1A2F515E5342E38248E03E9967AC1F4AAAE8E5365C58BB0A1ECAE857295D80C870305A2920A4BC32A61AC614AFCBC14F6CBCAB6F4722F1D41F0FE0EDEDE819964F4B7368EDC8472EF8C70EE2B2361A1C2F20226FDC4172EC0253E165587952BD277D873855C826A0FE4D7ECA03539FD0765269DE20DF99715267F51935510247BE9820E31ABB56B316AF77D6636EBFC13CDD9BA9219EB50973B04A12CDF87120EC77C41C02FD6CAFB20FB8571670BB4744059979530E28786B7A6E769C082E0D7A8E5FA4B3C7242627F91714EF40A129EF0A757EE37 +7E5332A3B84EF33E:00B9A48FA8058A2391BACB0413BBDEA70021476DFE960AA11E76BE0415CAE055D4E25DB547E1FA96814D3F1995609F1AA176D71708067533500169FED35E834E417E082E91DB24FBFE7C06CA12382DB1205DA0A525AB7DC0638B69EE93A59C51FBF38A2C89ADE05B166956E2F7799390E8B2DE1C0574622619C57C8D88EC8B0B91C40126356A21990E92C7732104E9CB13E70B1ED28221BED853596B7DC62D11D981D634C6272B27D15998F1260DB9ADB9F3D3AC7DFCE9675E421A0196A889144B8FC066CF17EA408ABC644E037EE47FD15D423A62BAA7638D3B8B951CBA42CCE2B8CD1807A25A64233BB92AC26EE6D606A2A74D2C98475F33C45902E2A6C7B80E +37EF192BE2750051:77541F192DB5B755115ADEF2C8C14F8D2712D3087D790FB0F5D134C7DA5BA6DC661156F9971586610F2D73C9083D6DB6E8978410CFFC0454CB7BA219D3B928E5A4779ACAD4AF72CC1F8557D7D649745E2F6BAAD06957AA34C7CBA164ECA9907CFD3BC18E9B082056424E831E684262A65B482AC53DFE65AE189F1C3C3B42673C1C22322C2F9F97B164EA31026BE711BE9AF128D586BCC3BFDD28591AC09CBF885A46583D13390EBE02AB0CE4A827BAD8C5A3AD9A5A2AB975CA6B2AD0B58F35A38604A598728F626E68236796833E72015B098B5D1F029011E3E19AFA7FFBEF6BB4D5C0C96D869BD6DE96EE18CDC1F0C13A30D6C6367F90D37AC88BF09BF1945D +00C4C187289937B8E3:27696442A4E507A30DB8234029F9ABA46124376051B5DE6B67D1B89F00FA79BB2D57D1A05C540351521B8ECA6A7FC74B1C7689A3706E08A40CC1F1EAD6886FB657DB5C7A28FBD331D524176007F88B2FE59F87CD5B98CE9FAA843BE415AD082BEC45720BEC97ABC9A46CAC5387F03121E8F582A06CD55F534B056E271679C1102EF52867393A46A0C4F6579945C4D338EF123B85A8CAC6B06578F32EE7B66E38240A005B95E3F7C637B076B955EDF9967D152795188959A733A6F225B4245173AC629EE3F71334E0CF5C98238EADFBF9E4F78DB9FB593EA5546378FBCF4902EB1A6113AEDB2E3E913B7941EB8C6759F32DF5FD0DDE50491D40D90753050641BB +0E98251C2BFEA0F1:6D480050E47EA73C1B9D8C625BD149C53EF1A6CF7ADA24CC177DC29712364EE28D3A80DAEC25BD4F3A6854AB5ECCE56F0F66532FEE9D9A728B69E9A60DD9AFD7B864504D1A2E41414EED9BB5170ECC68E094FF0D3F52067A7F7C37221B71E24D94D113383BEAB79BAB01E5BD89473BE3D8610B429B48D8867679DCF35E42D1FEB1D0CB4E2970FC200F6DCF1CEEDF2A46D71FA298E2C752C65AF8516F7EE03DFB4C386D3E6BB96EC8848BBCC8003777BA0E1AEBA2AEFFE5A2C1D8D2FB8E18D4D45F9A55834C7B0DED72DC8732D7B54C72E391E8E4E94017E522B6D38A99EAA1362A95539077356B304D67556D376FBFC06CE5E2D165BD63B0EBEF748E11C4B7E8 +682E0844E409AEDC:009700455FFA6C25BEB00A31DD1613CC94AFE28D339EDF703C235463158B5D40B26A3AB96A20872ACA98D6A1746C2CF4C69BBCCF93C18EC4DD451B80210B854F85722C0E8476C8460DA02076BB097BD27B77A63CBDAE69597FD7596A235512A1BD72B616CAA464EF872EC0812C2A35A298D5C18EDA76D3349BDB76B18CC9EBC2510D30998E203108F395060D1D1DED1537A2B9AEEF8AE4F8D077F6DE9A82CFFBA8CD1171B5DBD66E5CBF39320CC04F54D51E0AB2819C74C69F749153C93F9307FB274B79C66982CD57D41DBDC9A1FCA2E15EE0F6557B25681DE223A9BF596739D13C94F3893E66657BFFFD452840558C9857BB7725D873C093F1E72F6C34925F46 +76728A4999496B9C:04B793AF801AE18965DD0E37F21100950384B5D8059FC526F1143BD6BC182940F5E42392CC9534E8DAC1190E966F10DB619FC4F45B2AFFBB415F733E7CB971A5DDED0737A9B81646AE41C6742BFD6DD97CB1AEC7BAF923FF237C329FD4E307906B6ACB92F084626AC1E20FFB2BD780DCDFCD7460092E1DAF5AAC6CA56BC1D265B6BD02D1C45E868A289E294A2AEF784600D24EBD108686CF6AFA82D39A69DF508E0F28C7D31D2FBB3BF6E2D4226CCF197E92B02DBDBEEC04B03CD0D899997387D8CCE04AB41C02C4967FFB0CA19E8864360BD12A9DE5703F38B394C2EA8B7F6294823464911D479E7700CC6B68E07F23E9D69A9405E93928258FF771DDF7657E +00F00C6DB96830BD0A:00930DA0FB9918FE343B8CC5E77258FCC75860D15E6A6B72D3B955FB39C62162EE3638E14EAD1473D81D500F89FEF9F98CC0039271290775689F8728E87D93E9654E599E052088D35654DCCBB4E199EFB4EE88B2681CE79AB8D0E75EC07C25865173DFFB8865610FCE8B9450FF494A8CEC24BE3CC2EFD22FAE17F357663A3FF7C279175A9BDFD523C267EA6B24210C434A7682D25A38FB3F25BAB62E44D792AC4D0848DF462A68A3953380B6F67235F65FA68091893D7331D4C7DD93F79DA572405013ADD7D8FF28ECA4BF4FA97DF37E0D16C24F6CA06E952C722BED51D980B6B88D2B812CF88EC9F0BB717E974BD62076F177B4ED9EDDDFB479C590DCE2AA3F87 +046C3C377F612702:647D3FA8F730455CB553CA225891FE8A9C05BBB5D5EEF8A93536ED579D79C11C8B71CC2780E28718553FA2FB7EE7749624D98421D4F7125D941CFEA3A2D2BD5ACBE68970BE222079EF3EB7939C0E5A2EFC921E2261E35C93CEF2544EF8AF811D4D3292B488C6067B1B4F8C29DA303DE590A2264B072FCDCDB333EBAD51B8792883068436CAD86A1B3396FE371E928C7E854966FB8C021D4B0086EF718E612E2A926C321459EAA9E645F378E761BC467CF090750C385D56C2E3287BCD6646EE1F07DD9472980A72D22F82FAD5E8FB0E0B3E087E295A6EAB1BA22927B1E2EC6E213174C729DC00F2956CDF9E30BC2E17AC037B4FDF705C52F405473B6D61957D3A +00EF8540C5BC629D9B:00B423B022FAF9319FA8D7079BA64EEF3370AF01603D1122E742385E60D6FE6924A65412EF46A867076859D5DC32647F995933505F3DE83F7D8F2C7108AFE6D00DA0107E474729297BEC813F2D529A501D7ABE360345F12094BE558369B3CEA9BD5B61C990F5C6E0A7B5F5B64896F5DB75D4D0CE934C3E84E098092470833D518F6CB3779C199F7CDB2052561FC5B6F86B44299BE6C5420C199DA4F46FBEC220186CA086FBBC4E629AC7A2A0B637A440A993C96BDFC9B32EE00954C92D9194F079DBEEFE8B4BA636384EAC2A166408EB944DE41FB304837F10A5037C78F983E9B5DB7B44AB1D619825EC444815E169A904D77F7E9F74BF356097C566447BC3FD9A +59A5EE5E908DECF9:568344411E8EEE5E4B86EF8B468FDEFAC49EDBFE2D00F3A148FEC5D18B709F13E90D6936488F966805933C349DC5E61C12AC2DCE4B573F46D9F7FD85BBB4A9AC5996A83356D659DD75892D4E32272968B4F2B05944DE54C81C4476FC88C2C2A817F616D671B78EFD940DAB906B76D2695E8E582E3359031176BAD71C69831FEE68927A37742BCB707F6EC24B768B1BB325CF5B57FF239E263FBA35DFA65EE729E8D6FA0615A7D003F12476069569AFFF50BE05AC737EDDF8086D52E2801B7FEE9927EC4D60EA351E08EFF284FDBC66AD5AD0CA48B47EE187F41ED45290945D960436C3D581A9E05950F840F978854BBBF45492D408D6535D42E495D3D2D262D3 +33657640176515E9:663EF3A5401E0ED033094AE4D1F45E852742F7426273A03BB43FC6765EB722A8BF9802A042906570528613527B58B5B603851D5F5A73009FA16EC3BA35B7E61D9EE2E40653405151CF26B335C20E9DEF0EBFE5768DB4155D84B380E58E059CCAA526E3F2EBD01DD197863B715B9E6855D3A5442E78244F50049100DB9DF785C2418B0C6814B75DEE956E67E79D966641DCF81FF76609C79BB7432509E2777F74F52ACC239892654D1B7EA711133C28C23FF9167E13B096B41C30673B5049F759B389A460D9FF617CC539FC63EDBD1E3FE6D41C66D628F3FED99FBC159306CD879A0281C6B2B7DD0FC70AFC2ED7C68E1BA6C74B4FC8BB2280E6544556E31D564C +32C660AF720F1228:00ABB2A2B45B48D39E86F6FCC72974772EA337427AD64A8BDCFA625C938B2B162162AA9295527DFF6D1CD254966FD80FE014183E52F9A3DDBDBFED250900BD979E37AB158507CEEE849934D8C64DE6F064F300C7571335E3280BA05F4D4640141DBA54765B5643CF01FC3D99D103A87F03EC006D3499DCCD0CF4D553D004AA17AB8A17883B17E305A63540708A54507021B5CDBD8689AB2D2F273AD8BD5BD3A5E45BABD46A052153C3280AEA28297153EB079247D78B37C3E6251DDC80FD866FEB07A6ACA4098A34C25956D32F8947CCD94FB58085F1CC46B63ECD98797ACA16C8CB3B6C6D6953B91B0AEC958FCBC09201F4073C815AD539579B003D1F1C8303C2 +49F8BE8FCBD9AD8B:008EDA31256FE91B1C76B50413E3C0D934E4EBC83B0352EDF37CB279B835F57754FE91244D62F07A16C2B56C6ADEDAAAD8C07CB111846FADCDFF7EAE626F81933C4EB1C42026FB220B175DFACA9170492DB4221E4864FAA2D7F247D5052CC3E0EBE2B298FFFAEF84509822A1CD3B3B24A7F569BE7AB18A036F78A926605FF51F95F3DAEA40856FA1E3F6C0F9CC0B6B245545566CCBE0E6EBB8B74F8319AC3B9EA06FE31DAC0DD4E1289DDF1F5111F97D51C5A6E9652974F56D0D253FB1C7D8F67DCB52091C62D59458ADBA524FA23306BB816EB863AA7F4401B3DBD81197FC1C0D021EA04128EF02FB1BD65CC604BDC49F97B3794D660C2CE0E8F1A17E6BBBB51B diff --git a/xcode/lib-gpu-generate/publickey.txt b/xcode/lib-gpu-generate/publickey.txt @@ -0,0 +1,2 @@ +00BAF4220C41EBD7F0CB74BD9914CEF0D0F3C3C743B8EFA194CA13E25C387EFCD55DD8D4A18F076420D24151D72A0F1584FF1B58A7F6A39C7B0E862422A6BEE695C84C1769323331749609020D12E163D7CF890CE88E1EFFDFC8DFF2B870D8661FFE451DC3BF945383C8CBA9EF46202CC66CE3CAA76D1BB56842101957421E1D6F4023272E05ABD108F38C63A0F7BA13E1357E83C8BD72F8CD00755ED51FCDC745C3A3CCCB224FC2FEFED9E88E8650FD50B284AD3779DC5EB046826B21F03F4F5B41E97AB6C797DA6C4C0A7EE444779A53C0CE64B97AD4093A79779D879389C36E55A5E0B34F5EF031A20201D78FC702C54CC18AD85C2844190791F58970D79C5B +010001 diff --git a/xcode/lib-gpu-verify.xcodeproj/project.pbxproj b/xcode/lib-gpu-verify.xcodeproj/project.pbxproj @@ -7,8 +7,8 @@ objects = { /* Begin PBXBuildFile section */ - 6A8A795D2A89357400116D7D /* rsa-kernel.cl in Sources */ = {isa = PBXBuildFile; fileRef = 6A8A795C2A89357400116D7D /* rsa-kernel.cl */; }; 6A8A795F2A89672700116D7D /* verify.cl in Sources */ = {isa = PBXBuildFile; fileRef = 6A8A795E2A89672700116D7D /* verify.cl */; }; + 6AA38E5B2B0A97FC00E85243 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AA38E5A2B0A97FC00E85243 /* main.c */; }; 6AD85E072AF71AD900662919 /* big-int-test.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AF7487D2ADADF4500D58E08 /* big-int-test.c */; }; 6AD85E0C2AFA510C00662919 /* openssl-test.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AD85E0B2AFA510C00662919 /* openssl-test.c */; }; 6AF7487A2ADADEBD00D58E08 /* lib-gpu-verify.c in Sources */ = {isa = PBXBuildFile; fileRef = 6AF748792ADADEBD00D58E08 /* lib-gpu-verify.c */; }; @@ -18,6 +18,15 @@ /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ + 6AA38E562B0A97FC00E85243 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; C39444690DAFF5A0008FFE68 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -31,8 +40,10 @@ /* Begin PBXFileReference section */ 466E0F5F0C932E1A00ED01DB /* lib-gpu-verify */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "lib-gpu-verify"; sourceTree = BUILT_PRODUCTS_DIR; }; - 6A8A795C2A89357400116D7D /* rsa-kernel.cl */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.opencl; path = "rsa-kernel.cl"; sourceTree = "<group>"; }; 6A8A795E2A89672700116D7D /* verify.cl */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.opencl; path = verify.cl; sourceTree = "<group>"; }; + 6AA38E582B0A97FC00E85243 /* lib-gpu-generate */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "lib-gpu-generate"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6AA38E5A2B0A97FC00E85243 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; }; + 6AA38E612B0A9B2100E85243 /* lib-gpu-generate.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "lib-gpu-generate.entitlements"; sourceTree = "<group>"; }; 6AD85E0A2AFA510C00662919 /* openssl-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "openssl-test.h"; path = "../source/openssl-test.h"; sourceTree = "<group>"; }; 6AD85E0B2AFA510C00662919 /* openssl-test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "openssl-test.c"; path = "../source/openssl-test.c"; sourceTree = "<group>"; }; 6AF748792ADADEBD00D58E08 /* lib-gpu-verify.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "lib-gpu-verify.c"; path = "../source/lib-gpu-verify.c"; sourceTree = "<group>"; }; @@ -54,12 +65,20 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6AA38E552B0A97FC00E85243 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 466E0F490C93291B00ED01DB = { isa = PBXGroup; children = ( + 6AA38E592B0A97FC00E85243 /* lib-gpu-generate */, C3770EF30E6F10CF009A5A77 /* Frameworks */, C3770EF10E6F10BB009A5A77 /* Sources */, 466E0F600C932E1A00ED01DB /* Products */, @@ -70,6 +89,7 @@ isa = PBXGroup; children = ( 466E0F5F0C932E1A00ED01DB /* lib-gpu-verify */, + 6AA38E582B0A97FC00E85243 /* lib-gpu-generate */, ); name = Products; sourceTree = "<group>"; @@ -85,11 +105,19 @@ name = Headers; sourceTree = "<group>"; }; + 6AA38E592B0A97FC00E85243 /* lib-gpu-generate */ = { + isa = PBXGroup; + children = ( + 6AA38E612B0A9B2100E85243 /* lib-gpu-generate.entitlements */, + 6AA38E5A2B0A97FC00E85243 /* main.c */, + ); + path = "lib-gpu-generate"; + sourceTree = "<group>"; + }; C3770EF10E6F10BB009A5A77 /* Sources */ = { isa = PBXGroup; children = ( 6A984F162AC5B18A00F530FD /* Headers */, - 6A8A795C2A89357400116D7D /* rsa-kernel.cl */, 6A8A795E2A89672700116D7D /* verify.cl */, 6AF748792ADADEBD00D58E08 /* lib-gpu-verify.c */, 6AD85E0B2AFA510C00662919 /* openssl-test.c */, @@ -128,6 +156,23 @@ productReference = 466E0F5F0C932E1A00ED01DB /* lib-gpu-verify */; productType = "com.apple.product-type.tool"; }; + 6AA38E572B0A97FC00E85243 /* lib-gpu-generate */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6AA38E5C2B0A97FC00E85243 /* Build configuration list for PBXNativeTarget "lib-gpu-generate" */; + buildPhases = ( + 6AA38E542B0A97FC00E85243 /* Sources */, + 6AA38E552B0A97FC00E85243 /* Frameworks */, + 6AA38E562B0A97FC00E85243 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "lib-gpu-generate"; + productName = "lib-gpu-generate"; + productReference = 6AA38E582B0A97FC00E85243 /* lib-gpu-generate */; + productType = "com.apple.product-type.tool"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -136,6 +181,11 @@ attributes = { BuildIndependentTargetsInParallel = YES; LastUpgradeCheck = 1500; + TargetAttributes = { + 6AA38E572B0A97FC00E85243 = { + CreatedOnToolsVersion = 15.0.1; + }; + }; }; buildConfigurationList = 466E0F4E0C93291B00ED01DB /* Build configuration list for PBXProject "lib-gpu-verify" */; compatibilityVersion = "Xcode 2.4"; @@ -153,6 +203,7 @@ projectRoot = ""; targets = ( 466E0F5E0C932E1A00ED01DB /* lib-gpu-verify */, + 6AA38E572B0A97FC00E85243 /* lib-gpu-generate */, ); }; /* End PBXProject section */ @@ -165,13 +216,20 @@ 6AD85E0C2AFA510C00662919 /* openssl-test.c in Sources */, 6AD85E072AF71AD900662919 /* big-int-test.c in Sources */, 6AF7487A2ADADEBD00D58E08 /* lib-gpu-verify.c in Sources */, - 6A8A795D2A89357400116D7D /* rsa-kernel.cl in Sources */, 6A8A795F2A89672700116D7D /* verify.cl in Sources */, 6AF748832ADADF4500D58E08 /* rsa-test.c in Sources */, 6AF748862ADADFAD00D58E08 /* opencl-test.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; + 6AA38E542B0A97FC00E85243 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6AA38E5B2B0A97FC00E85243 /* main.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ @@ -307,6 +365,98 @@ }; name = Release; }; + 6AA38E5D2B0A97FC00E85243 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "lib-gpu-generate/lib-gpu-generate.entitlements"; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = 3QL75UNV78; + ENABLE_HARDENED_RUNTIME = NO; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + HEADER_SEARCH_PATHS = ( + ../../inc, + /usr/local/include, + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../lib\"", + "\"/usr/local/lib\"", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + OTHER_LDFLAGS = "-lgcrypt"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Debug; + }; + 6AA38E5E2B0A97FC00E85243 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "lib-gpu-generate/lib-gpu-generate.entitlements"; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = 3QL75UNV78; + ENABLE_HARDENED_RUNTIME = NO; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + HEADER_SEARCH_PATHS = ( + ../../inc, + /usr/local/include, + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../lib\"", + "\"/usr/local/lib\"", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + OTHER_LDFLAGS = "-lgcrypt"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -328,6 +478,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 6AA38E5C2B0A97FC00E85243 /* Build configuration list for PBXNativeTarget "lib-gpu-generate" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6AA38E5D2B0A97FC00E85243 /* Debug */, + 6AA38E5E2B0A97FC00E85243 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 466E0F4B0C93291B00ED01DB /* Project object */; diff --git a/xcode/lib-gpu-verify.xcodeproj/project.xcworkspace/xcuserdata/cedriczwahlen.xcuserdatad/UserInterfaceState.xcuserstate b/xcode/lib-gpu-verify.xcodeproj/project.xcworkspace/xcuserdata/cedriczwahlen.xcuserdatad/UserInterfaceState.xcuserstate Binary files differ. diff --git a/xcode/lib-gpu-verify.xcodeproj/xcshareddata/xcschemes/lib-gpu-generate.xcscheme b/xcode/lib-gpu-verify.xcodeproj/xcshareddata/xcschemes/lib-gpu-generate.xcscheme @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "1500" + version = "1.7"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "6AA38E572B0A97FC00E85243" + BuildableName = "lib-gpu-generate" + BlueprintName = "lib-gpu-generate" + ReferencedContainer = "container:lib-gpu-verify.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES" + shouldAutocreateTestPlan = "YES"> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "YES" + customWorkingDirectory = "/Users/cedriczwahlen/libgpuverify/xcode/lib-gpu-generate" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES" + viewDebuggingEnabled = "No"> + <BuildableProductRunnable + runnableDebuggingMode = "0"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "6AA38E572B0A97FC00E85243" + BuildableName = "lib-gpu-generate" + BlueprintName = "lib-gpu-generate" + ReferencedContainer = "container:lib-gpu-verify.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + <CommandLineArguments> + <CommandLineArgument + argument = "16" + isEnabled = "YES"> + </CommandLineArgument> + </CommandLineArguments> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + <BuildableProductRunnable + runnableDebuggingMode = "0"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "6AA38E572B0A97FC00E85243" + BuildableName = "lib-gpu-generate" + BlueprintName = "lib-gpu-generate" + ReferencedContainer = "container:lib-gpu-verify.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/xcode/lib-gpu-verify.xcodeproj/xcuserdata/cedriczwahlen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/xcode/lib-gpu-verify.xcodeproj/xcuserdata/cedriczwahlen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -683,223 +683,6 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent - uuid = "8CC35C0B-FC9A-4FA3-841F-C77B239866FA" - shouldBeEnabled = "No" - ignoreCount = "0" - continueAfterRunningActions = "No" - filePath = "../source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "732" - endingLineNumber = "732" - landmarkName = "rsa_tests()" - landmarkType = "9"> - <Locations> - <Location - uuid = "8CC35C0B-FC9A-4FA3-841F-C77B239866FA - b0b9078e770c98da" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "316" - endingLineNumber = "316" - offsetFromSymbolStart = "2796"> - </Location> - <Location - uuid = "8CC35C0B-FC9A-4FA3-841F-C77B239866FA - b0b9078e770c98da" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "316" - endingLineNumber = "316" - offsetFromSymbolStart = "2782"> - </Location> - </Locations> - </BreakpointContent> - </BreakpointProxy> - <BreakpointProxy - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> - <BreakpointContent - uuid = "CCA5ECFD-4BDD-4A9B-8C34-A3E9A049CB5C" - shouldBeEnabled = "No" - ignoreCount = "0" - continueAfterRunningActions = "No" - filePath = "../source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "746" - endingLineNumber = "746" - landmarkName = "rsa_tests()" - landmarkType = "9"> - <Locations> - <Location - uuid = "CCA5ECFD-4BDD-4A9B-8C34-A3E9A049CB5C - b0b9078e770c9a09" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "329" - endingLineNumber = "329" - offsetFromSymbolStart = "3113"> - </Location> - <Location - uuid = "CCA5ECFD-4BDD-4A9B-8C34-A3E9A049CB5C - b0b9078e770c9a09" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "329" - endingLineNumber = "329" - offsetFromSymbolStart = "3202"> - </Location> - <Location - uuid = "CCA5ECFD-4BDD-4A9B-8C34-A3E9A049CB5C - b0b9078e770c9ae8" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "330" - endingLineNumber = "330" - offsetFromSymbolStart = "3202"> - </Location> - <Location - uuid = "CCA5ECFD-4BDD-4A9B-8C34-A3E9A049CB5C - b0b9078e770c9985" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "325" - endingLineNumber = "325" - offsetFromSymbolStart = "3192"> - </Location> - <Location - uuid = "CCA5ECFD-4BDD-4A9B-8C34-A3E9A049CB5C - b0b9078e770c9985" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "325" - endingLineNumber = "325" - offsetFromSymbolStart = "3218"> - </Location> - <Location - uuid = "CCA5ECFD-4BDD-4A9B-8C34-A3E9A049CB5C - b0b9078e770c9985" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "325" - endingLineNumber = "325" - offsetFromSymbolStart = "3240"> - </Location> - <Location - uuid = "CCA5ECFD-4BDD-4A9B-8C34-A3E9A049CB5C - b0b9078e770c9985" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "325" - endingLineNumber = "325" - offsetFromSymbolStart = "3264"> - </Location> - <Location - uuid = "CCA5ECFD-4BDD-4A9B-8C34-A3E9A049CB5C - b0b9078e770c9985" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "325" - endingLineNumber = "325" - offsetFromSymbolStart = "3204"> - </Location> - <Location - uuid = "CCA5ECFD-4BDD-4A9B-8C34-A3E9A049CB5C - b0b9078e770c9985" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - symbolName = "rsa_tests" - moduleName = "lib-gpu-verify" - usesParentBreakpointCondition = "Yes" - urlString = "file:///Users/cedriczwahlen/libgpuverify/source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "325" - endingLineNumber = "325" - offsetFromSymbolStart = "3208"> - </Location> - </Locations> - </BreakpointContent> - </BreakpointProxy> - <BreakpointProxy - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> - <BreakpointContent - uuid = "C1B34A3E-98EE-448B-A02F-A50E969F7C92" - shouldBeEnabled = "No" - ignoreCount = "0" - continueAfterRunningActions = "No" - filePath = "../source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "929" - endingLineNumber = "929" - landmarkName = "verify(sign, ee, nn, mm)" - landmarkType = "9"> - </BreakpointContent> - </BreakpointProxy> - <BreakpointProxy - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> - <BreakpointContent uuid = "6E42D663-F5A4-4A31-A6DB-269D03688D3D" shouldBeEnabled = "No" ignoreCount = "0" @@ -1393,22 +1176,6 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent - uuid = "1C1C50D0-346F-426D-BD58-8F706A2DD395" - shouldBeEnabled = "Yes" - ignoreCount = "0" - continueAfterRunningActions = "No" - filePath = "../source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "956" - endingLineNumber = "956" - landmarkName = "unknown" - landmarkType = "0"> - </BreakpointContent> - </BreakpointProxy> - <BreakpointProxy - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> - <BreakpointContent uuid = "6AF0F685-479D-4405-BACC-8368C49802BF" shouldBeEnabled = "Yes" ignoreCount = "0" @@ -1496,8 +1263,8 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "67" - endingLineNumber = "67" + startingLineNumber = "71" + endingLineNumber = "71" landmarkName = "generate_random_pairs(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> </BreakpointContent> @@ -1512,8 +1279,8 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "442" - endingLineNumber = "442" + startingLineNumber = "448" + endingLineNumber = "448" landmarkName = "rsa_tests()" landmarkType = "9"> <Locations> @@ -1688,22 +1455,6 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent - uuid = "570B7C5C-BA80-46F3-A54C-51A33A4B0A75" - shouldBeEnabled = "No" - ignoreCount = "0" - continueAfterRunningActions = "No" - filePath = "../source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "917" - endingLineNumber = "917" - landmarkName = "verify(sign, ee, nn, mm)" - landmarkType = "9"> - </BreakpointContent> - </BreakpointProxy> - <BreakpointProxy - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> - <BreakpointContent uuid = "E76A4300-645A-48D3-AFAA-F40E9454639D" shouldBeEnabled = "No" ignoreCount = "0" @@ -1711,9 +1462,9 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "431" - endingLineNumber = "431" - landmarkName = "rsa_tests()" + startingLineNumber = "435" + endingLineNumber = "435" + landmarkName = "verify_with_opencl(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> <Locations> <Location @@ -1804,8 +1555,8 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "107" - endingLineNumber = "107" + startingLineNumber = "111" + endingLineNumber = "111" landmarkName = "generate_random_pairs(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> </BreakpointContent> @@ -1813,22 +1564,6 @@ <BreakpointProxy BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> <BreakpointContent - uuid = "B481E43C-61F8-4041-948A-4170903D293D" - shouldBeEnabled = "No" - ignoreCount = "0" - continueAfterRunningActions = "No" - filePath = "../source/rsa-test.c" - startingColumnNumber = "9223372036854775807" - endingColumnNumber = "9223372036854775807" - startingLineNumber = "902" - endingLineNumber = "902" - landmarkName = "verify(sign, ee, nn, mm)" - landmarkType = "9"> - </BreakpointContent> - </BreakpointProxy> - <BreakpointProxy - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> - <BreakpointContent uuid = "73F6BB7B-689A-4F98-A7F8-5693DAF77398" shouldBeEnabled = "No" ignoreCount = "0" @@ -1836,8 +1571,8 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "134" - endingLineNumber = "134" + startingLineNumber = "138" + endingLineNumber = "138" landmarkName = "generate_random_pairs(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> </BreakpointContent> @@ -1852,8 +1587,8 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "129" - endingLineNumber = "129" + startingLineNumber = "133" + endingLineNumber = "133" landmarkName = "generate_random_pairs(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> <Locations> @@ -1945,9 +1680,9 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "403" - endingLineNumber = "403" - landmarkName = "rsa_tests()" + startingLineNumber = "407" + endingLineNumber = "407" + landmarkName = "verify_with_opencl(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> </BreakpointContent> </BreakpointProxy> @@ -1961,8 +1696,8 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "310" - endingLineNumber = "310" + startingLineNumber = "314" + endingLineNumber = "314" landmarkName = "verify_with_opencl(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> <Locations> @@ -2009,9 +1744,9 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "419" - endingLineNumber = "419" - landmarkName = "rsa_tests()" + startingLineNumber = "423" + endingLineNumber = "423" + landmarkName = "verify_with_opencl(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> <Locations> <Location @@ -2102,8 +1837,8 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "366" - endingLineNumber = "366" + startingLineNumber = "370" + endingLineNumber = "370" landmarkName = "verify_with_opencl(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> <Locations> @@ -2150,9 +1885,9 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "410" - endingLineNumber = "410" - landmarkName = "rsa_tests()" + startingLineNumber = "414" + endingLineNumber = "414" + landmarkName = "verify_with_opencl(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> <Locations> <Location @@ -2198,8 +1933,8 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "333" - endingLineNumber = "333" + startingLineNumber = "337" + endingLineNumber = "337" landmarkName = "verify_with_opencl(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> </BreakpointContent> @@ -2214,11 +1949,89 @@ filePath = "../source/rsa-test.c" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "420" - endingLineNumber = "420" - landmarkName = "rsa_tests()" + startingLineNumber = "424" + endingLineNumber = "424" + landmarkName = "verify_with_opencl(bases, b_len, exponents, e_len, moduli, m_len, signatures, s_len, n)" landmarkType = "9"> </BreakpointContent> </BreakpointProxy> + <BreakpointProxy + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> + <BreakpointContent + uuid = "FB9B9AD4-F59B-4392-927C-1207B6B04BBF" + shouldBeEnabled = "Yes" + ignoreCount = "0" + continueAfterRunningActions = "No" + filePath = "lib-gpu-generate/main.c" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "123" + endingLineNumber = "123" + landmarkName = "main(argc, argv)" + landmarkType = "9"> + <Locations> + <Location + uuid = "FB9B9AD4-F59B-4392-927C-1207B6B04BBF - e0abeefb3692e836" + shouldBeEnabled = "Yes" + ignoreCount = "0" + continueAfterRunningActions = "No" + symbolName = "main" + moduleName = "lib-gpu-generate" + usesParentBreakpointCondition = "Yes" + urlString = "file:///Users/cedriczwahlen/libgpuverify/xcode/lib-gpu-generate/main.c" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "129" + endingLineNumber = "129" + offsetFromSymbolStart = "791"> + </Location> + <Location + uuid = "FB9B9AD4-F59B-4392-927C-1207B6B04BBF - e0abeefb3692e9f4" + shouldBeEnabled = "Yes" + ignoreCount = "0" + continueAfterRunningActions = "No" + symbolName = "main" + moduleName = "lib-gpu-generate" + usesParentBreakpointCondition = "Yes" + urlString = "file:///Users/cedriczwahlen/libgpuverify/xcode/lib-gpu-generate/main.c" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "127" + endingLineNumber = "127" + offsetFromSymbolStart = "831"> + </Location> + <Location + uuid = "FB9B9AD4-F59B-4392-927C-1207B6B04BBF - e0abeefb3692e9f4" + shouldBeEnabled = "Yes" + ignoreCount = "0" + continueAfterRunningActions = "No" + symbolName = "main" + moduleName = "lib-gpu-generate" + usesParentBreakpointCondition = "Yes" + urlString = "file:///Users/cedriczwahlen/libgpuverify/xcode/lib-gpu-generate/main.c" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "127" + endingLineNumber = "127" + offsetFromSymbolStart = "827"> + </Location> + <Location + uuid = "FB9B9AD4-F59B-4392-927C-1207B6B04BBF - e0abeefb3692e970" + shouldBeEnabled = "Yes" + ignoreCount = "0" + continueAfterRunningActions = "No" + symbolName = "main" + moduleName = "lib-gpu-generate" + usesParentBreakpointCondition = "Yes" + urlString = "file:///Users/cedriczwahlen/libgpuverify/xcode/lib-gpu-generate/main.c" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "123" + endingLineNumber = "123" + offsetFromSymbolStart = "727"> + </Location> + </Locations> + </BreakpointContent> + </BreakpointProxy> </Breakpoints> </Bucket> diff --git a/xcode/lib-gpu-verify.xcodeproj/xcuserdata/cedriczwahlen.xcuserdatad/xcschemes/xcschememanagement.plist b/xcode/lib-gpu-verify.xcodeproj/xcuserdata/cedriczwahlen.xcuserdatad/xcschemes/xcschememanagement.plist @@ -4,6 +4,11 @@ <dict> <key>SchemeUserState</key> <dict> + <key>lib-gpu-generate.xcscheme_^#shared#^_</key> + <dict> + <key>orderHint</key> + <integer>1</integer> + </dict> <key>lib-gpu-verify.xcscheme_^#shared#^_</key> <dict> <key>orderHint</key> @@ -17,6 +22,11 @@ <key>primary</key> <true/> </dict> + <key>6AA38E572B0A97FC00E85243</key> + <dict> + <key>primary</key> + <true/> + </dict> </dict> </dict> </plist> diff --git a/xcode/rsa-kernel.cl b/xcode/rsa-kernel.cl @@ -1,12 +0,0 @@ - - -__kernel void -square (__global float* input, - __global float* output, - const unsigned int count) -{ - int i = get_global_id(0); - - if(i < count) - output[i] = input[i] * input[i]; -} diff --git a/xcode/verify.cl b/xcode/verify.cl @@ -1205,10 +1205,10 @@ void assert(bool precondition) { // Moreover, s_len is initialized as a *single* // size_t (not even a pointer!), // but treated as an array here!??!? -__kernel void several(__global DIGIT_T* x, __global const size_t *s_len, - __global DIGIT_T* e, __global const size_t *e_len, - __global DIGIT_T* m, __global const size_t *n_len, - __global DIGIT_T *mm, __global const size_t *mm_len, +__kernel void several(__global DIGIT_T* x, __global const unsigned long *s_len, + __global DIGIT_T* e, __global const unsigned long *e_len, + __global DIGIT_T* m, __global const unsigned long *n_len, + __global DIGIT_T *mm, __global const unsigned long *mm_len, __global unsigned long* valid, const int count ) { @@ -1227,7 +1227,7 @@ __kernel void several(__global DIGIT_T* x, __global const size_t *s_len, DIGIT_T yout[MAX_ALLOC_SIZE *2]; DIGIT_T mask; - size_t n; + unsigned long n; __global DIGIT_T * __private window_x; __global DIGIT_T * __private window_e;