diff options
author | Werner Koch <[email protected]> | 2009-05-08 15:07:45 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2009-05-08 15:07:45 +0000 |
commit | eeca39ae50bcb7dfb1089b37658de4f02a0c1f9a (patch) | |
tree | 266e3cd4fa755d134bfdab7c8727b7f226313af0 /scd/app-help.c | |
parent | New helper function factored out of ../scd and equipped with test code. (diff) | |
download | gnupg-eeca39ae50bcb7dfb1089b37658de4f02a0c1f9a.tar.gz gnupg-eeca39ae50bcb7dfb1089b37658de4f02a0c1f9a.zip |
More support for Netkey cards.
Small changes to teh CCID driver.
Support 2048 bit OpenPGP cards.
Diffstat (limited to 'scd/app-help.c')
-rw-r--r-- | scd/app-help.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/scd/app-help.c b/scd/app-help.c index 83b34c64e..3d9c605f6 100644 --- a/scd/app-help.c +++ b/scd/app-help.c @@ -1,5 +1,5 @@ /* app-help.c - Application helper functions - * Copyright (C) 2004 Free Software Foundation, Inc. + * Copyright (C) 2004, 2009 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -28,6 +28,30 @@ #include "iso7816.h" #include "tlv.h" + +/* Count the number of bits, assuming the A represents an unsigned big + integer of length LEN bytes. If A is NULL a length of 0 is + returned. */ +unsigned int +app_help_count_bits (const unsigned char *a, size_t len) +{ + unsigned int n = len * 8; + int i; + + if (!a) + return 0; + + for (; len && !*a; len--, a++, n -=8) + ; + if (len) + { + for (i=7; i && !(*a & (1<<i)); i--) + n--; + } + return n; +} + + /* Return the KEYGRIP for the certificate CERT as an hex encoded string in the user provided buffer HEXKEYGRIP which must be of at least 41 bytes. */ |