{"action":"created","issue":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/462","labels_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/462/labels{/name}","comments_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/462/comments","events_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/462/events","html_url":"https://github.com/nodemcu/nodemcu-firmware/pull/462","id":83789940,"number":462,"title":"Crypto module","user":{"login":"jmattsson","id":869607,"avatar_url":"https://avatars.githubusercontent.com/u/869607?v=3","gravatar_id":"","url":"https://api.github.com/users/jmattsson","html_url":"https://github.com/jmattsson","followers_url":"https://api.github.com/users/jmattsson/followers","following_url":"https://api.github.com/users/jmattsson/following{/other_user}","gists_url":"https://api.github.com/users/jmattsson/gists{/gist_id}","starred_url":"https://api.github.com/users/jmattsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmattsson/subscriptions","organizations_url":"https://api.github.com/users/jmattsson/orgs","repos_url":"https://api.github.com/users/jmattsson/repos","events_url":"https://api.github.com/users/jmattsson/events{/privacy}","received_events_url":"https://api.github.com/users/jmattsson/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-06-02T02:05:24Z","updated_at":"2015-06-03T09:23:16Z","closed_at":"2015-06-02T08:21:03Z","pull_request":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/462","html_url":"https://github.com/nodemcu/nodemcu-firmware/pull/462","diff_url":"https://github.com/nodemcu/nodemcu-firmware/pull/462.diff","patch_url":"https://github.com/nodemcu/nodemcu-firmware/pull/462.patch"},"body":"Hi there,\r\n\r\nI don't know if there's any interest in this, but we've built a small crypto module for exposing MD2/MD5/SHA1 and optionally SHA{256,384,512} in Lua, as well as the HMAC versions of these.\r\n\r\nI imported Aaron Gifford's SHA256 code into libssl since that seemed the most appropriate location, though currently the SSL library does not make use of it. Feel free to move it somewhere else if you want. The crypto module (standalone commit 20bc8f4) can be built without the SHA256 support if WITHOUT_SHA2 is defined, making it useful even without the Gifford code.\r\n\r\nExample usage:\r\n\r\n    local hash = crypto.hash('MD5', \"abc\")\r\n    local signature = crypto.hmac('SHA256', \"abc\", \"mysecretkey\")\r\n\r\nKnown limitations:\r\n- HMAC keys must not exceed the block length of the chosen hash function\r\n- While I'm familiar with Lua, I'm new to NodeMCU so a certain measure of \"monkey see, monkey do\" was used in the making of this module..."},"comment":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/comments/108263504","html_url":"https://github.com/nodemcu/nodemcu-firmware/pull/462#issuecomment-108263504","issue_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/462","id":108263504,"user":{"login":"TerryE","id":690173,"avatar_url":"https://avatars.githubusercontent.com/u/690173?v=3","gravatar_id":"","url":"https://api.github.com/users/TerryE","html_url":"https://github.com/TerryE","followers_url":"https://api.github.com/users/TerryE/followers","following_url":"https://api.github.com/users/TerryE/following{/other_user}","gists_url":"https://api.github.com/users/TerryE/gists{/gist_id}","starred_url":"https://api.github.com/users/TerryE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TerryE/subscriptions","organizations_url":"https://api.github.com/users/TerryE/orgs","repos_url":"https://api.github.com/users/TerryE/repos","events_url":"https://api.github.com/users/TerryE/events{/privacy}","received_events_url":"https://api.github.com/users/TerryE/received_events","type":"User","site_admin":false},"created_at":"2015-06-03T09:23:16Z","updated_at":"2015-06-03T09:23:16Z","body":"Thanks Cal, a very useful summary.  The ESP8266 is a _closed source_ SoC, so the details are quite murky. It has at least two CPUs on the die. The main CPU is an Xtensa LX.  This is comparable to the bottom end of the ARM range of CPUs.  (There's also a I/O CPU for the WiFI)  The system runs at 80MHz and ROM access will run pretty much at full throttle.  Flash access is pretty slow in comparison, but there is as Cal says a 32KB RAM cache in front of this (again details are murky)."}}