diff options
author | Jim Rees <rees@cvs.openbsd.org> | 2001-07-26 22:15:05 +0000 |
---|---|---|
committer | Jim Rees <rees@cvs.openbsd.org> | 2001-07-26 22:15:05 +0000 |
commit | e07abeaf01e979a706a0593ee59f1ee1af177479 (patch) | |
tree | cbde07ee6829853a0ce3d56b1dc18d5b574257c3 /lib | |
parent | f144d03fc437e99f15ed8fdd8067c1d9ddda60b7 (diff) |
sectok_fmt_fid now takes a proper fid
add cyberflex_create_file_acl
put proper acls on public and private rsa key files
bump major version
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libsectok/cyberflex.c | 26 | ||||
-rw-r--r-- | lib/libsectok/input.c | 7 | ||||
-rw-r--r-- | lib/libsectok/sectok.c | 12 | ||||
-rw-r--r-- | lib/libsectok/sectok.h | 5 | ||||
-rw-r--r-- | lib/libsectok/shlib_version | 2 |
5 files changed, 35 insertions, 17 deletions
diff --git a/lib/libsectok/cyberflex.c b/lib/libsectok/cyberflex.c index 31c95300956..47e63cfca7d 100644 --- a/lib/libsectok/cyberflex.c +++ b/lib/libsectok/cyberflex.c @@ -1,4 +1,4 @@ -/* $Id: cyberflex.c,v 1.7 2001/07/02 20:07:07 rees Exp $ */ +/* $Id: cyberflex.c,v 1.8 2001/07/26 22:15:04 rees Exp $ */ /* copyright 2000 @@ -57,9 +57,8 @@ such damages. #define BLOCK_SIZE 8 int -cyberflex_create_file(int fd, int cla, unsigned char *fid, int size, int ftype, int *swp) +cyberflex_create_file_acl(int fd, int cla, unsigned char *fid, int size, int ftype, unsigned char *acl, int *swp) { - int i; unsigned char data[16]; size += 16; @@ -71,9 +70,7 @@ cyberflex_create_file(int fd, int cla, unsigned char *fid, int size, int ftype, data[4] = ftype; data[5] = 0x01; /* status = 1 */ data[6] = data[7] = 0x00; /* record related */ - data[8] = 0xff; /* ACL can do everything with AUT0 */ - for (i = 9; i < 16; i++ ) - data[i] = 0x00; /* ACL : cannot do anything without AUT0 */ + memmove(&data[8], acl, 8); sectok_apdu(fd, cla, 0xe0, 0, 0, 0x10, data, 0, NULL, swp); if (!sectok_swOK(*swp)) @@ -82,6 +79,16 @@ cyberflex_create_file(int fd, int cla, unsigned char *fid, int size, int ftype, return sectok_selectfile(fd, cla, fid, swp); } +/* Create a file with default acl "world: r w x/a inval rehab dec inc" */ + +int +cyberflex_create_file(int fd, int cla, unsigned char *fid, int size, int ftype, int *swp) +{ + static unsigned char acl[] = {0xff, 0, 0, 0, 0, 0, 0, 0}; + + return cyberflex_create_file_acl(fd, cla, fid, size, ftype, acl, swp); +} + int cyberflex_delete_file(int fd, int cla, unsigned char *fid, int *swp) { @@ -96,11 +103,13 @@ int cyberflex_load_rsa_pub(int fd, int cla, unsigned char *key_fid, int key_len, unsigned char *key_data, int *swp) { + static unsigned char acl[] = {0x1, 0, 0, 0xb, 0, 0, 0, 0}; + if (sectok_selectfile(fd, cla, root_fid, swp) < 0) return -1; if (sectok_selectfile(fd, cla, key_fid, swp) < 0 && *swp == STENOFILE) { - if (cyberflex_create_file(fd, cla, key_fid, key_len, 3, swp) < 0) + if (cyberflex_create_file_acl(fd, cla, key_fid, key_len, 3, acl, swp) < 0) return -1; } @@ -120,6 +129,7 @@ cyberflex_load_rsa_priv(int fd, int cla, unsigned char *key_fid, { int i, j, offset = 0, size; unsigned char data[MAX_KEY_FILE_SIZE]; + static unsigned char acl[] = {0, 0, 0, 0xa, 0, 0, 0, 0}; /* AUT0: w inval */ static unsigned char key_file_header[KEY_FILE_HEADER_SIZE] = {0xC2, 0x06, 0xC1, 0x08, 0x13, 0x00, 0x00, 0x05}; static unsigned char key_header[3] = {0xC2, 0x41, 0x00}; @@ -131,7 +141,7 @@ cyberflex_load_rsa_priv(int fd, int cla, unsigned char *key_fid, /* select 00.12 */ if (sectok_selectfile(fd, cla, key_fid, swp) < 0 && *swp == STENOFILE) { /* rv != 0, 00.12 does not exist. create it. */ - if (cyberflex_create_file(fd, cla, key_fid, PRV_KEY_SIZE, 3, swp) < 0) + if (cyberflex_create_file_acl(fd, cla, key_fid, PRV_KEY_SIZE, 3, acl, swp) < 0) return -1; } diff --git a/lib/libsectok/input.c b/lib/libsectok/input.c index 971981095ac..caa39f0fcba 100644 --- a/lib/libsectok/input.c +++ b/lib/libsectok/input.c @@ -1,4 +1,4 @@ -/* $Id: input.c,v 1.5 2001/07/02 20:07:08 rees Exp $ */ +/* $Id: input.c,v 1.6 2001/07/26 22:15:04 rees Exp $ */ /* copyright 2001 @@ -137,9 +137,10 @@ sectok_parse_input(char *ibuf, unsigned char *obuf, int olen) void sectok_parse_fname(char *buf, unsigned char *fid) { - if (buf[0] == '/' || sectok_parse_input(buf, fid, 2) < 2) { + fid[1] = 0; + + if (buf[0] == '/' || sectok_parse_input(buf, fid, 2) < 1) { /* root */ fid[0] = 0x3f; - fid[1] = 0; } } diff --git a/lib/libsectok/sectok.c b/lib/libsectok/sectok.c index d79be37c8f9..d92147b1947 100644 --- a/lib/libsectok/sectok.c +++ b/lib/libsectok/sectok.c @@ -1,4 +1,4 @@ -/* $Id: sectok.c,v 1.6 2001/07/17 16:57:17 rees Exp $ */ +/* $Id: sectok.c,v 1.7 2001/07/26 22:15:04 rees Exp $ */ /* copyright 2000 @@ -460,9 +460,15 @@ sectok_apdu(int fd, int cla, int ins, int p1, int p2, } void -sectok_fmt_fid(char *fname, int f0, int f1) +sectok_fmt_fid(char *fname, unsigned char *fid) { - if (myisprint(f0) && myisprint(f1)) + int f0 = fid[0], f1 = fid[1]; + + if (f0 == 0x3f && f1 == 0) + sprintf(fname, "/"); + else if (myisprint(f0) && f1 == 0) + sprintf(fname, "%c", f0); + else if (myisprint(f0) && myisprint(f1)) sprintf(fname, "%c%c", f0, f1); else sprintf(fname, "%02x%02x", f0, f1); diff --git a/lib/libsectok/sectok.h b/lib/libsectok/sectok.h index 6c269b28511..c2955ff1125 100644 --- a/lib/libsectok/sectok.h +++ b/lib/libsectok/sectok.h @@ -1,4 +1,4 @@ -/* $Id: sectok.h,v 1.12 2001/07/20 15:51:45 rees Exp $ */ +/* $Id: sectok.h,v 1.13 2001/07/26 22:15:04 rees Exp $ */ /* copyright 2001 @@ -79,7 +79,7 @@ int sectok_close(int fd); int sectok_selectfile(int fd, int cla, unsigned char *fid, int *swp); /* Convenience functions */ -void sectok_fmt_fid(char *fname, int f0, int f1); +void sectok_fmt_fid(char *fname, unsigned char *fid); int sectok_parse_atr(int fd, int flags, unsigned char *atr, int len, struct scparam *param); void sectok_parse_fname(char *buf, unsigned char *fid); int sectok_parse_input(char *ibuf, unsigned char *obuf, int olen); @@ -94,6 +94,7 @@ char *sectok_get_ins(int ins); /* Cyberflex functions */ int cyberflex_create_file(int fd, int cla, unsigned char *fid, int size, int ftype, int *swp); +int cyberflex_create_file_acl(int fd, int cla, unsigned char *fid, int size, int ftype, unsigned char *acl, int *swp); int cyberflex_delete_file(int fd, int cla, unsigned char *fid, int *swp); int cyberflex_load_rsa_pub(int fd, int cla, unsigned char *key_fid, int key_len, unsigned char *key_data, int *swp); diff --git a/lib/libsectok/shlib_version b/lib/libsectok/shlib_version index b52599a164f..012c14171d3 100644 --- a/lib/libsectok/shlib_version +++ b/lib/libsectok/shlib_version @@ -1,2 +1,2 @@ -major=2 +major=3 minor=0 |