]> www.average.org Git - pam_pcsc_cr.git/commitdiff
authobj - new interface works
authorEugene Crosser <crosser@average.org>
Sun, 1 Dec 2013 18:33:40 +0000 (22:33 +0400)
committerEugene Crosser <crosser@average.org>
Sun, 1 Dec 2013 18:33:40 +0000 (22:33 +0400)
authobj.c
test_auth.c

index adc101b087c426b71f86a977ef7b95b1dbc1b917..224cbb56b9df63998bb35ad7db846da77fe4fd95 100644 (file)
--- a/authobj.c
+++ b/authobj.c
@@ -158,19 +158,19 @@ parse_authobj(const unsigned char *key, const int keysize,
 
                serial_init(&srl, ao.buffer, bufsize);
                if (serial_get(&srl, (void**)&ao.data, &ao.datasize)) {
 
                serial_init(&srl, ao.buffer, bufsize);
                if (serial_get(&srl, (void**)&ao.data, &ao.datasize)) {
-                       ao.err = "parse authobj: too long secret";
+                       ao.err = "mismatch: impossible secret";
                } else if (serial_get(&srl, (void**)&ao.payload, &ao.paylsize)) {
                } else if (serial_get(&srl, (void**)&ao.payload, &ao.paylsize)) {
-                       ao.err = "parse authobj: too long payload";
+                       ao.err = "mismatch: impossible payload";
                } else if ((rc = hash(ao.buffer, serial_size(&srl),
                                        myhash, &myhsize))) {
                        ao.err = crypto_errstr(rc);
                } else if (serial_get(&srl, (void**)&theirhash, &theirhsize)) {
                } else if ((rc = hash(ao.buffer, serial_size(&srl),
                                        myhash, &myhsize))) {
                        ao.err = crypto_errstr(rc);
                } else if (serial_get(&srl, (void**)&theirhash, &theirhsize)) {
-                       ao.err = "parse authobj: too long hash";
+                       ao.err = "mismatch: impossible hash";
                } else if (theirhsize != HASHSIZE) {
                } else if (theirhsize != HASHSIZE) {
-                       ao.err = "parse authobj: hash is of wrong size";
+                       ao.err = "mismatch: hash is of wrong size";
                } else if ((myhsize != theirhsize) ||
                                memcmp(myhash, theirhash, myhsize)) {
                } else if ((myhsize != theirhsize) ||
                                memcmp(myhash, theirhash, myhsize)) {
-                       ao.err = "parse authobj: hash mismatch";
+                       ao.err = "mismatch: different hash";
                }
        }
        return ao;
                }
        }
        return ao;
index 421c8b93149e3c232cf3e36673b9433f3e515ef0..177fb5f26abf6639034148e2e942d5a1f6c822c6 100644 (file)
@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
        const char *id = "testuser";
        const char *pass = "testpassword";
        const char *nonce = "1";
        const char *id = "testuser";
        const char *pass = "testpassword";
        const char *nonce = "1";
-       const unsigned char secret[] = {0xb4, 0x62, 0xf2, 0x60, 0x87,
+       unsigned char secret[] = {0xb4, 0x62, 0xf2, 0x60, 0x87,
                                        0x78, 0x16, 0x87, 0xde, 0xce,
                                        0x80, 0x09, 0x24, 0x0b, 0x93,
                                        0xfc, 0xa0, 0xfc, 0x56, 0x56};
                                        0x78, 0x16, 0x87, 0xde, 0xce,
                                        0x80, 0x09, 0x24, 0x0b, 0x93,
                                        0xfc, 0xa0, 0xfc, 0x56, 0x56};
@@ -19,7 +19,11 @@ int main(int argc, char *argv[])
        struct _auth_obj ao;
        struct _auth_obj nao;
 
        struct _auth_obj ao;
        struct _auth_obj nao;
 
-       printf("using crypto %s\n", crypto_init(0));
+       if (argc == 2 && strlen(argv[1]) == 40 &&
+                       strspn(argv[1], "0123456789abcdefABCDEF") == 40) {
+               for (i = 0; i < sizeof(secret); i++)
+                       sscanf(&argv[1][i*2], "%2hhx", &secret[i]);
+       }
        ao = new_authobj(id, pass, nonce, secret, sizeof(secret),
                        payload, strlen((char *)payload));
        printf("new_authobj err=%s\n", ao.err?ao.err:"<no error>");
        ao = new_authobj(id, pass, nonce, secret, sizeof(secret),
                        payload, strlen((char *)payload));
        printf("new_authobj err=%s\n", ao.err?ao.err:"<no error>");