/* The host side of the bcrypt implementation is based on hello_world.c * Modified by Katja Malvoni to fit the bcrypt implementation */ /* hello_world.c Copyright (C) 2012 Adapteva, Inc. Contributed by Yaniv Sapir This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program, see the file COPYING. If not, see . */ #include #include #include #include #include #include typedef unsigned int BF_word; typedef BF_word BF_binary[6]; typedef struct { int start[16]; BF_binary parallella_BF_out[16]; int core_done[16]; int done; int test[16]; char ciphertext[16]; } data; #define _BufSize (sizeof(data)) #define _BufOffset (0x01000000) struct fmt_tests { char *ciphertext, *plaintext; char *fields[10]; }; static struct fmt_tests test[] = { {"$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW", "U*U"}, {"$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK", "U*U*"}, {"$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a", "U*U*U"}, {"$2a$05$CCCCCCCCCCCCCCCCCCCCC.7uG0VCzI2bS7j6ymqJi9CdcdxiRTWNy", ""}, {"$2a$05$abcdefghijklmnopqrstuu5s2v8.iXieOjg/.AySBTTZIIVFJeBui", "0123456789abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "chars after 72 are ignored"}, {"$2x$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e", "\xa3"}, {"$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq", "\xa3"}, {"$2x$05$6bNw2HLQYeqHYyBfLMsv/OiwqTymGIGzFsA4hOTWebfehXHNprcAS", "\xd1\x91"}, {"$2x$05$6bNw2HLQYeqHYyBfLMsv/O9LIGgn8OMzuDoHfof8AQimSGfcSWxnS", "\xd0\xc1\xd2\xcf\xcc\xd8"}, {"$2a$05$/OK.fbVrR/bpIqNJ5ianF.swQOIzjOiJ9GHEPuhEkvqrUyvWhEMx6", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "chars after 72 are ignored as usual"}, {"$2a$05$/OK.fbVrR/bpIqNJ5ianF.R9xrDjiycxMbQE2bp.vgqlYpW5wx2yy", "\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55" "\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55" "\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55" "\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55" "\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55" "\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55"}, {"$2a$05$CCCCCCCCCCCCCCCCCCCCC.7uG0VCzI2bS7j6ymqJi9CdcdxiRTWNy", ""}, {"$2a$05$/OK.fbVrR/bpIqNJ5ianF.9tQZzcJfm3uj2NvJ/n5xkhpqLrMpWCe", "\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff" "\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff" "\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff" "\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff" "\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff" "\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff"}, {NULL} }; int main(int argc, char *argv[]) { e_platform_t platform; e_epiphany_t dev; e_mem_t emem; volatile data result; struct timeval start, end; int i, j, k, a = 0; int go = 0; e_init(NULL); if(e_reset_system() == E_ERR) { fprintf(stderr, "Reset failed!\n"); fflush(stderr); exit(1); } e_get_platform_info(&platform); e_alloc(&emem, _BufOffset, _BufSize); e_open(&dev, 0, 0, platform.rows, platform.cols); if(e_load_group("e_bcrypt.srec", &dev, 0, 0, platform.rows, platform.cols, e_true) == E_ERR) { fprintf(stderr, "Load failed!\n"); fflush(stderr); exit(-1); } result.done = 0; //for(a = 0; a < 14; a++) //{ while(result.done) e_read(&emem, 0, 0, offsetof(data, done), (void *)&result.done, sizeof(result.done)); //key for(i = 0; i < platform.rows; i++) for(j = 0; j < platform.cols; j++) e_write(&dev, i, j, 0x7800, test[a].plaintext, 72 + 1); //salt for(i = 0; i < platform.rows; i++) for(j = 0; j < platform.cols; j++) e_write(&dev, i, j, 0x7700, test[a].ciphertext, 61); result.start[0] = 16; e_write(&emem, 0, 0, offsetof(data, start[0]), (void *)&result.start[0], sizeof(result.start[0])); gettimeofday(&start, NULL); result.done = 0; // Wait for core program execution to finish while(result.done != 16) //sleep(1); e_read(&emem, 0, 0, 0x0, (void *)&result, _BufSize); gettimeofday(&end, NULL); for(i = 0; i < platform.rows; i++) { for(j = 0; j < platform.cols; j++) { fprintf(stderr, "eCore 0x%03x (%d, %d): %x", ((i + platform.row) * 64 + j + platform.col), i, j, result.parallella_BF_out[i*platform.rows + j][0]); for(k = 1; k < 6; k++) fprintf(stderr, ", %x", result.parallella_BF_out[i*platform.rows + j][k]); fprintf(stderr, "\n"); } } fprintf(stderr, "Execution time - Epiphany: %f ms\n", (double)(end.tv_sec - start.tv_sec)*1000 + ((double)(end.tv_usec - start.tv_usec)/1000.0)); fprintf(stderr, "done = %d\n", result.done); for(i = 0; i < 16; i++) fprintf(stderr, "core_done[%2d] = %d\t test[%2d] = %d\t ciphertext[%d] = %c\n", i, result.core_done[i], i, result.test[i], i, result.ciphertext[i]); printf("ciphertext = %c\n", test[a].ciphertext[32]); //} e_close(&dev); e_free(&emem); e_finalize(); return 0; }