/* 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 typedef unsigned int BF_word; typedef BF_word BF_binary[6]; typedef struct { BF_binary parallella_BF_out[16]; int done; } 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[]) { unsigned row, col, coreid; e_platform_t platform; e_epiphany_t dev; e_mem_t emem; data result; struct timeval start, end; int i, j, k, a = 0; //char hash[] = "$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW"; //char key1[] = "U*U"; //char key2[] = "U*U"; 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); for(a = 0; a < 14; a++) { row = 0; col = 0; //coreid = (row + platform.row) * 64 + col + platform.col; //fprintf(stderr, "Message from eCore 0x%03x (%2d,%2d): ", coreid, row, col); fflush(stderr); e_open(&dev, 0, 0, platform.rows, platform.cols); //key e_write(&dev, 0, 0, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 0, 1, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 0, 2, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 0, 3, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 1, 0, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 1, 1, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 1, 2, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 1, 3, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 2, 0, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 2, 1, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 2, 2, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 2, 3, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 3, 0, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 3, 1, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 3, 2, 0x7800, test[a].plaintext, 72 + 1); e_write(&dev, 3, 3, 0x7800, test[a].plaintext, 72 + 1); //hash e_write(&dev, 0, 0, 0x7700, test[a].ciphertext, 61); e_write(&dev, 0, 1, 0x7700, test[a].ciphertext, 61); e_write(&dev, 0, 2, 0x7700, test[a].ciphertext, 61); e_write(&dev, 0, 3, 0x7700, test[a].ciphertext, 61); e_write(&dev, 1, 0, 0x7700, test[a].ciphertext, 61); e_write(&dev, 1, 1, 0x7700, test[a].ciphertext, 61); e_write(&dev, 1, 2, 0x7700, test[a].ciphertext, 61); e_write(&dev, 1, 3, 0x7700, test[a].ciphertext, 61); e_write(&dev, 2, 0, 0x7700, test[a].ciphertext, 61); e_write(&dev, 2, 1, 0x7700, test[a].ciphertext, 61); e_write(&dev, 2, 2, 0x7700, test[a].ciphertext, 61); e_write(&dev, 2, 3, 0x7700, test[a].ciphertext, 61); e_write(&dev, 3, 0, 0x7700, test[a].ciphertext, 61); e_write(&dev, 3, 1, 0x7700, test[a].ciphertext, 61); e_write(&dev, 3, 2, 0x7700, test[a].ciphertext, 61); e_write(&dev, 3, 3, 0x7700, test[a].ciphertext, 61); gettimeofday(&start, NULL); 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); } // Wait for core program execution to finish while(result.done != 16) //sleep(1); e_read(&emem, 0, 0, 0x0, &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); } e_close(&dev); e_free(&emem); e_finalize(); return 0; }