Fix configure typo, type punning pointers

This commit is contained in:
NIIBE Yutaka
2013-02-25 15:46:02 +09:00
parent 16610ca5c7
commit 1564a4fbe6
4 changed files with 15 additions and 6 deletions

View File

@@ -1,3 +1,12 @@
2013-02-25 Niibe Yutaka <gniibe@fsij.org>
* src/configure: Correct typo in help text.
* src/gnuk.h (struct key_data_internal): Use uint32_t.
* src/openpgp-do.c (do_openpgpcard_aid): Fix calculation of VID.
(compute_key_data_checksum): Don't use type-punning pointer.
(gpg_do_write_prvkey): Use coercing to char *.
2013-02-22 Niibe Yutaka <gniibe@fsij.org>
* src/openpgp-do.c (GPG_DO_DISCRETIONARY, cmp_discretionary): New.

2
src/configure vendored
View File

@@ -84,7 +84,7 @@ Configuration:
-h, --help display this help and exit [no]
--vidpid=VID:PID specify vendor/product ID [<NONE>]
--target=TARGET specify target [OLIMEX_STM32_H103]
supported targes are:
supported targets are:
OLIMEX_STM32_H103
STM32_PRIMER2
CQ_STARM

View File

@@ -171,8 +171,8 @@ struct key_data {
};
struct key_data_internal {
uint8_t data[KEY_CONTENT_LEN]; /* p and q */
uint8_t checksum[DATA_ENCRYPTION_KEY_SIZE];
uint32_t data[KEY_CONTENT_LEN/4]; /* p and q */
uint32_t checksum[DATA_ENCRYPTION_KEY_SIZE/4];
};
struct prvkey_data {

View File

@@ -447,7 +447,7 @@ const uint8_t openpgpcard_aid[] = {
static int
do_openpgpcard_aid (uint16_t tag, int with_tag)
{
uint16_t vid = *((const volatile uint16_t *)&openpgpcard_aid[8]);
uint16_t vid = (openpgpcard_aid[8] << 8) | openpgpcard_aid[9];
if (with_tag)
{
@@ -664,7 +664,7 @@ compute_key_data_checksum (struct key_data_internal *kdi, int check_or_calc)
uint32_t d[4] = { 0, 0, 0, 0 };
for (i = 0; i < KEY_CONTENT_LEN / sizeof (uint32_t); i++)
d[i&3] ^= *(uint32_t *)(&kdi->data[i*4]);
d[i&3] ^= kdi->data[i];
if (check_or_calc == 0) /* store */
{
@@ -790,7 +790,7 @@ gpg_do_write_prvkey (enum kind_of_key kk, const uint8_t *key_data, int key_len,
encrypt (dek, iv, (uint8_t *)&kdi, sizeof (struct key_data_internal));
r = flash_key_write (key_addr, kdi.data, modulus);
r = flash_key_write (key_addr, (const uint8_t *)kdi.data, modulus);
if (modulus_allocated_here)
modulus_free (modulus);