Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decrypt function is missing PIN promise/check #4

Open
martinl opened this issue Apr 29, 2017 · 1 comment
Open

decrypt function is missing PIN promise/check #4

martinl opened this issue Apr 29, 2017 · 1 comment

Comments

@martinl
Copy link

martinl commented Apr 29, 2017

Here is a patch, should I create a pull request?

--- ../esteid-dev/esteid.js    2017-04-29 15:46:20.000000000 +0300
+++ esteid.js   2017-04-27 10:59:02.000000000 +0300
@@ -242,8 +242,16 @@
             header[0] = chunks.length === 0 ? 0x00 : 0x10
             header[4] = chunk.length
             var cmd = Buffer.concat([header, chunk, Buffer.from([0x00])])
-            apdu.check(transmit(cmd)).then(function (r) {
-              if (chunks.length === 0) { return resolve(apdu.data(r)) } else { return decr() }
+            // verify PIN1 and decrypt
+            return eid.verify(eid.PIN1, pin).then(function () {
+              apdu.check(transmit(cmd)).then(function (r) {
+                if (chunks.length === 0) {
+                  return resolve(apdu.data(r))
+                }
+                else {
+                  return decr()
+                }
+              })
             }).catch(function (reason) {
               console.log('Decryption failed')
               reject(reason)
@martinl martinl changed the title decrypt function is missing PIN promise check decrypt function is missing PIN promise/check Apr 29, 2017
@martinpaljak
Copy link
Owner

Indeed. Please do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants