{"action":"closed","issue":{"url":"https://api.github.com/repos/abderraouf-adjal/ArduinoSpritzCipher/issues/6","repository_url":"https://api.github.com/repos/abderraouf-adjal/ArduinoSpritzCipher","labels_url":"https://api.github.com/repos/abderraouf-adjal/ArduinoSpritzCipher/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/abderraouf-adjal/ArduinoSpritzCipher/issues/6/comments","events_url":"https://api.github.com/repos/abderraouf-adjal/ArduinoSpritzCipher/issues/6/events","html_url":"https://github.com/abderraouf-adjal/ArduinoSpritzCipher/issues/6","id":304216819,"number":6,"title":"Encrypt/decrypt success rate a function of key size","user":{"login":"jmusther","id":32524315,"avatar_url":"https://avatars1.githubusercontent.com/u/32524315?v=4","gravatar_id":"","url":"https://api.github.com/users/jmusther","html_url":"https://github.com/jmusther","followers_url":"https://api.github.com/users/jmusther/followers","following_url":"https://api.github.com/users/jmusther/following{/other_user}","gists_url":"https://api.github.com/users/jmusther/gists{/gist_id}","starred_url":"https://api.github.com/users/jmusther/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmusther/subscriptions","organizations_url":"https://api.github.com/users/jmusther/orgs","repos_url":"https://api.github.com/users/jmusther/repos","events_url":"https://api.github.com/users/jmusther/events{/privacy}","received_events_url":"https://api.github.com/users/jmusther/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-03-12T01:41:35Z","updated_at":"2018-03-12T19:11:52Z","closed_at":"2018-03-12T19:11:52Z","author_association":"NONE","body":"When performing encrypt followed by decrypt, the success rate (defined as the frequency at which the plaintext is regenerated) appears to be dependent on the key length.  I ran repetitive encrypt/decrypt cycles with different key lengths and found that:\r\nA key length of 128 bytes results in about a 2% success rate\r\n64 byte key results in about 75%\r\n48 byte key results in about 80% \r\n32 byte key results in about 90%\r\n16 byte key results in about 98%\r\n\r\nEach of these tests ran for over 2000 cycles.  \r\n\r\nHere's the code:\r\n`#include <SpritzCipher.h>\r\n\r\nlong total = 0;\r\nlong success = 0;\r\n\r\nconst PROGMEM byte key[16] = {0xF4, 0x88, 0xE6, 0x3B, 0xA3, 0x1A, 0x79, 0x7F, 0x8D, 0x4C, 0x10, 0xEC, 0xB2, 0x1F, 0x84, 0x91};\r\n                               \r\nvoid spritzEnc(byte msg[], byte msgLen, const byte *key, byte keyLen){\r\n  spritz_ctx s_ctx;\r\n\r\n  spritz_setup(&s_ctx, key, keyLen);\r\n  spritz_crypt(&s_ctx, msg, msgLen, msg);\r\n}\r\n\r\nvoid spritzDec(byte msg[], byte msgLen, const byte *key, byte keyLen){\r\n  spritz_ctx s_ctx;\r\n\r\n  spritz_setup(&s_ctx, key, keyLen);\r\n  spritz_crypt(&s_ctx, msg, msgLen, msg);\r\n}\r\n\r\nvoid setup() {\r\n  /* Initialize serial and wait for port to open */\r\n  Serial.begin(9600);\r\n  while (!Serial) {\r\n    ; /* Wait for serial port to connect. Needed for Leonardo only */\r\n  }\r\n\r\n  /* initialize digital pin LED_BUILTIN (Most boards have this LED connected to digital pin 13) as an output */\r\n  pinMode(LED_BUILTIN, OUTPUT);\r\n  digitalWrite(LED_BUILTIN, LOW);\r\n}\r\n\r\nvoid loop() {\r\n  byte testMsg[4] = { 'A', 'B', 'C', 'S'};\r\n  \r\n  spritzEnc(testMsg, sizeof(testMsg), key, sizeof(key));    // Encrypt\r\n\r\n  spritzDec(testMsg, sizeof(testMsg), key, sizeof(key));    // Decrypt\r\n\r\n  if (testMsg[0] == 'A' && testMsg[1] == 'B' && testMsg[2] == 'C' && testMsg[3] == 'S'){\r\n    success = success + 1;\r\n  }\r\n  total = total + 1;\r\n  float sp = (float(success) / float(total))*100.0;\r\n\r\n  Serial.print(\"Cycles = \");\r\n  Serial.print(total);\r\n  Serial.print(\" success = \");\r\n  Serial.print(success);\r\n  Serial.print(\" or \");\r\n  Serial.print(sp, 2);\r\n  Serial.println(\" %\");\r\n\r\n}\r\n`\r\n"}}
{"actor":{"display_login":"jmusther"}}