moved all uthash related code into keyhash.c

This commit is contained in:
TLINDEN
2013-11-13 13:06:01 +01:00
parent bdaa7aae46
commit 5a8e3ee8b0
21 changed files with 209 additions and 93 deletions

View File

@@ -31,6 +31,10 @@
without headers and comments and don't know what
it is.
Moved all uthash (key lists) related code into
keyhash.c, so nowhere will be used any HASH*
macros directly.
0.1.4 Changed key format (again), now the main secret
is the ED25519 secret key, which will be encrypted.
Everything else will be derived from that. Thanks

View File

@@ -8,12 +8,14 @@ find . -name Makefile.in -exec rm {} \;
find . -name "*~" -exec rm {} \;
find . -name config.h -exec rm {} \;
find . -name stamp.h -exec rm {} \;
find . -name stamp-h1 -exec rm {} \;
find . -name .deps -exec rm -rf {} \;
find . -name .libs -exec rm -rf {} \;
find . -name .o -exec rm -rf {} \;
find . -name .lo -exec rm -rf {} \;
rm -rf configure config.* config autom4te.cache tests/test* tests/v* tests/stresstest/*
rm -rf configure config.* config autom4te.cache tests/test* tests/v* tests/stresstest/* \
libpcp/libpcp1.pc
set +x
# generate the install include file

View File

@@ -6,6 +6,7 @@ PCPEXPORT = pcp.h \
pcp/getpass.h \
pcp/jenhash.h \
pcp/key.h \
pcp/keyhash.h \
pcp/mac.h \
pcp/mem.h \
pcp/pad.h \

View File

@@ -225,6 +225,7 @@ PCPEXPORT = pcp.h \
pcp/getpass.h \
pcp/jenhash.h \
pcp/key.h \
pcp/keyhash.h \
pcp/mac.h \
pcp/mem.h \
pcp/pad.h \

View File

@@ -12,6 +12,7 @@ extern "C" {
#include "pcp/getpass.h"
#include "pcp/jenhash.h"
#include "pcp/key.h"
#include "pcp/keyhash.h"
#include "pcp/mac.h"
#include "pcp/mem.h"
#include "pcp/pad.h"

View File

@@ -110,9 +110,6 @@ struct _pcp_pubkey_t {
typedef struct _pcp_key_t pcp_key_t;
typedef struct _pcp_pubkey_t pcp_pubkey_t;
pcp_key_t *pcpkey_hash;
pcp_pubkey_t *pcppubkey_hash;
void pcp_cleanhashes();
pcp_key_t *pcpkey_new ();

63
include/pcp/keyhash.h Normal file
View File

@@ -0,0 +1,63 @@
/*
This file is part of Pretty Curved Privacy (pcp1).
Copyright (C) 2013 T.Linden.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact me by mail: <tlinden AT cpan DOT org>.
*/
#ifndef _HAVE_KEYHASH_H
#define _HAVE_KEYHASH_H
#ifdef __cplusplus
extern "C" {
#endif
#include "uthash.h"
#include "key.h"
pcp_key_t *pcpkey_hash;
pcp_pubkey_t *pcppubkey_hash;
pcp_key_t *__k;
pcp_pubkey_t *__p;
// wrapper for HASH_ITER
#define pcphash_iterate(key) \
__k = NULL; \
HASH_ITER(hh, pcpkey_hash, key, __k)
#define pcphash_iteratepub(key) \
__p = NULL; \
HASH_ITER(hh, pcppubkey_hash, key, __p)
void pcphash_init();
void pcphash_del(void *key, int type);
void pcphash_clean();
pcp_key_t *pcphash_keyexists(char *id);
pcp_pubkey_t *pcphash_pubkeyexists(char *id);
void pcphash_add(void *key, int type);
int pcphash_count();
int pcphash_countpub();
#ifdef __cplusplus
}
#endif
#endif // _HAVE_KEYHASH_H

View File

@@ -28,6 +28,6 @@ pkgconfig_DATA = libpcp1.pc
libpcp1_la_SOURCES = mac.c mem.c pad.c version.c \
z85.c zmq_z85.c key.c randomart.c \
vault.c fatal.c jenhash.c digital_crc32.c \
crypto.c ed.c
crypto.c ed.c keyhash.c
include_HEADERS = ../include/pcp.h

View File

@@ -101,7 +101,7 @@ LTLIBRARIES = $(lib_LTLIBRARIES)
libpcp1_la_LIBADD =
am_libpcp1_la_OBJECTS = mac.lo mem.lo pad.lo version.lo z85.lo \
zmq_z85.lo key.lo randomart.lo vault.lo fatal.lo jenhash.lo \
digital_crc32.lo crypto.lo ed.lo
digital_crc32.lo crypto.lo ed.lo keyhash.lo
libpcp1_la_OBJECTS = $(am_libpcp1_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/pcp
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
@@ -269,7 +269,7 @@ pkgconfig_DATA = libpcp1.pc
libpcp1_la_SOURCES = mac.c mem.c pad.c version.c \
z85.c zmq_z85.c key.c randomart.c \
vault.c fatal.c jenhash.c digital_crc32.c \
crypto.c ed.c
crypto.c ed.c keyhash.c
include_HEADERS = ../include/pcp.h
all: all-am
@@ -357,6 +357,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fatal.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jenhash.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/key.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyhash.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mac.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pad.Plo@am__quote@

View File

@@ -21,7 +21,7 @@
#include "key.h"
#include "keyhash.h"
unsigned char *pcp_derivekey(char *passphrase) {
unsigned char *hash32 = ucmalloc(crypto_hash_sha256_BYTES);
@@ -175,7 +175,6 @@ pcp_key_t *pcpkey_decrypt(pcp_key_t *key, char *passphrase) {
if(es == 0) {
// success
byte secret[32] = { 0 };
byte edsec[64] = { 0 };
pcp_ed_keypairs(secret, decrypted);
memcpy(key->secret, secret, 32);
memcpy(key->edsecret, decrypted, 64);
@@ -226,45 +225,6 @@ unsigned char *pcpkey_getchecksum(pcp_key_t *k) {
}
void pcp_inithashes() {
pcpkey_hash = NULL;
pcppubkey_hash = NULL;
}
void pcp_cleanhashes() {
if(pcpkey_hash != NULL) {
pcp_key_t *current_key, *tmp;
HASH_ITER(hh, pcpkey_hash, current_key, tmp) {
HASH_DEL(pcpkey_hash,current_key);
memset(current_key, 0, sizeof(pcp_key_t));
free(current_key); // FIXME: coredumps here after n-th secret keys has been added
}
}
if(pcppubkey_hash != NULL) {
pcp_pubkey_t *current_pub, *ptmp;
HASH_ITER(hh, pcppubkey_hash, current_pub, ptmp) {
HASH_DEL(pcppubkey_hash,current_pub);
memset(current_pub, 0, sizeof(pcp_pubkey_t));
free(current_pub);
}
}
pcp_inithashes();
}
pcp_key_t *pcpkey_exists(char *id) {
pcp_key_t *key = NULL;
HASH_FIND_STR(pcpkey_hash, id, key);
return key; // maybe NULL!
}
pcp_pubkey_t *pcppubkey_exists(char *id) {
pcp_pubkey_t *key = NULL;
HASH_FIND_STR(pcppubkey_hash, id, key);
return key; // maybe NULL!
}
pcp_key_t * key2be(pcp_key_t *k) {
k->version = htobe32(k->version);
k->serial = htobe32(k->serial);

90
libpcp/keyhash.c Normal file
View File

@@ -0,0 +1,90 @@
/*
This file is part of Pretty Curved Privacy (pcp1).
Copyright (C) 2013 T.Linden.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact me by mail: <tlinden AT cpan DOT org>.
*/
#include "keyhash.h"
void pcphash_init() {
pcpkey_hash = NULL;
pcppubkey_hash = NULL;
}
void pcphash_del(void *key, int type) {
if(type == PCP_KEY_TYPE_SECRET) {
HASH_DEL(pcpkey_hash, (pcp_key_t *)key);
memset(key, 0, sizeof(pcp_key_t));
}
else {
HASH_DEL(pcppubkey_hash, (pcp_pubkey_t *)key);
memset(key, 0, sizeof(pcp_pubkey_t));
}
free(key);
}
void pcphash_clean() {
if(pcpkey_hash != NULL) {
pcp_key_t *current_key, *tmp;
HASH_ITER(hh, pcpkey_hash, current_key, tmp) {
pcphash_del(current_key, PCP_KEY_TYPE_SECRET);
}
}
if(pcppubkey_hash != NULL) {
pcp_pubkey_t *current_pub, *ptmp;
HASH_ITER(hh, pcppubkey_hash, current_pub, ptmp) {
pcphash_del(current_pub, PCP_KEY_TYPE_PUBLIC);
}
}
pcphash_init();
}
pcp_key_t *pcphash_keyexists(char *id) {
pcp_key_t *key = NULL;
HASH_FIND_STR(pcpkey_hash, id, key);
return key; // maybe NULL!
}
pcp_pubkey_t *pcphash_pubkeyexists(char *id) {
pcp_pubkey_t *key = NULL;
HASH_FIND_STR(pcppubkey_hash, id, key);
return key; // maybe NULL!
}
void pcphash_add(void *key, int type) {
if(type == PCP_KEY_TYPE_PUBLIC) {
pcp_pubkey_t *k = (pcp_pubkey_t *)key;
HASH_ADD_STR( pcppubkey_hash, id, k );
}
else {
pcp_key_t *k = (pcp_key_t *)key;
HASH_ADD_STR( pcpkey_hash, id, k);
}
}
int pcphash_count() {
return HASH_COUNT(pcpkey_hash);
}
int pcphash_countpub() {
return HASH_COUNT(pcppubkey_hash);
}

View File

@@ -21,6 +21,7 @@
#include "vault.h"
#include "keyhash.h"
vault_t *pcpvault_init(char *filename) {
vault_t *vault = pcpvault_new(filename, 0);
@@ -151,14 +152,7 @@ int pcpvault_additem(vault_t *vault, void *item, size_t itemsize, uint8_t type,
if(do_hash == 1) {
// we don't re-hash if it's a full update
if(type == PCP_KEY_TYPE_PUBLIC) {
pcp_pubkey_t *p = (pcp_pubkey_t *)item;
HASH_ADD_STR( pcppubkey_hash, id, p );
}
else {
pcp_key_t *s = (pcp_key_t *)item;
HASH_ADD_STR( pcpkey_hash, id, s );
}
pcphash_add(item, type);
pcpvault_update_checksum(vault);
}
@@ -204,13 +198,13 @@ int pcpvault_writeall(vault_t *vault) {
vault_t *tmp = pcpvault_new(vault->filename, 1);
if(tmp != NULL) {
if(pcpvault_create(tmp) == 0) {
pcp_key_t *k, *kt = NULL;
HASH_ITER(hh, pcpkey_hash, k, kt) {
pcp_key_t *k = NULL;
pcphash_iterate(k) {
if(pcpvault_additem(tmp, (void *)k, sizeof(pcp_key_t), PCP_KEY_TYPE_SECRET, 0) != 0)
goto errwa;
}
pcp_pubkey_t *p, *pt = NULL;
HASH_ITER(hh, pcppubkey_hash, p, pt) {
pcp_pubkey_t *p = NULL;
pcphash_iteratepub(p) {
if(pcpvault_additem(tmp, (void *)p, sizeof(pcp_pubkey_t), PCP_KEY_TYPE_PUBLIC, 0) != 0)
goto errwa;
}
@@ -253,24 +247,24 @@ unsigned char *pcpvault_create_checksum(vault_t *vault) {
size_t skeysize = sizeof(pcp_key_t) - sizeof(UT_hash_handle);
size_t pkeysize = sizeof(pcp_pubkey_t) - sizeof(UT_hash_handle);
int numskeys = HASH_COUNT(pcpkey_hash);
int numpkeys = HASH_COUNT(pcppubkey_hash);
int numskeys = pcphash_count();
int numpkeys = pcphash_countpub();
size_t datasize = (skeysize * numskeys) + (pkeysize * numpkeys);
unsigned char *data = ucmalloc(datasize);
unsigned char *checksum = ucmalloc(32);
size_t datapos = 0;
pcp_key_t *k, *kt = NULL;
HASH_ITER(hh, pcpkey_hash, k, kt) {
pcp_key_t *k = NULL;
pcphash_iterate(k) {
key2be(k);
memcpy(&data[datapos], k, skeysize);
key2native(k);
datapos += skeysize;
}
pcp_pubkey_t *p, *pt = NULL;
HASH_ITER(hh, pcppubkey_hash, p, pt) {
pcp_pubkey_t *p = NULL;
pcphash_iteratepub(p) {
pubkey2be(p);
memcpy(&data[datapos], p, pkeysize);
pubkey2native(p);
@@ -374,14 +368,14 @@ int pcpvault_fetchall(vault_t *vault) {
if(header->fileid == PCP_VAULT_ID && header->version == PCP_VAULT_VERSION) {
// loop over the file and slurp everything in
pcpkey_hash = NULL;
pcppubkey_hash = NULL;
int readpos = 0;
pcp_key_t *key;
pcp_pubkey_t *pubkey;
int bytesleft = 0;
int ksize = sizeof(pcp_pubkey_t); // smallest possbile item
pcphash_init();
vault->version = header->version;
memcpy(vault->checksum, header->checksum, 32);
@@ -405,14 +399,14 @@ int pcpvault_fetchall(vault_t *vault) {
fread(key, sizeof(pcp_key_t), 1, vault->fd);
key2native(key);
//pcp_dumpkey(key);
HASH_ADD_STR( pcpkey_hash, id, key );
pcphash_add((void *)key, item->type);
}
else if(item->type == PCP_KEY_TYPE_PUBLIC) {
// read a public key
pubkey = ucmalloc(sizeof(pcp_pubkey_t));
fread(pubkey, sizeof(pcp_pubkey_t), 1, vault->fd);
pubkey2native(pubkey);
HASH_ADD_STR( pcppubkey_hash, id, pubkey );
pcphash_add((void *)pubkey, item->type);
}
else {
fatal("Failed to read vault - invalid key type: %02X! at %d\n", item->type, readpos);
@@ -443,7 +437,7 @@ int pcpvault_fetchall(vault_t *vault) {
unsigned char *checksum = NULL;
checksum = pcpvault_create_checksum(vault);
if(HASH_COUNT(pcpkey_hash) + HASH_COUNT(pcppubkey_hash) > 0) {
if(pcphash_count() + pcphash_countpub() > 0) {
// only validate the checksum if there are keys
if(memcmp(checksum, vault->checksum, 32) != 0) {
fatal("Error: the checksum of the key vault doesn't match its contents!\n");
@@ -459,7 +453,7 @@ int pcpvault_fetchall(vault_t *vault) {
err:
free(item);
free(header);
pcp_cleanhashes();
//pcphash_clean();
return -1;
}

View File

@@ -124,7 +124,7 @@
.\" ========================================================================
.\"
.IX Title "PCP1 1"
.TH PCP1 1 "2013-11-12" "PCP 0.1.5" "USER CONTRIBUTED DOCUMENTATION"
.TH PCP1 1 "2013-11-13" "PCP 0.1.5" "USER CONTRIBUTED DOCUMENTATION"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l

View File

@@ -93,9 +93,7 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd) {
unsigned char *check = ucmalloc(crypto_hash_BYTES);
memcpy(hash, combined, crypto_hash_BYTES);
for(public=pcppubkey_hash;
public != NULL;
public=(pcp_pubkey_t*)(public->hh.next)) {
pcphash_iteratepub(public) {
crypto_hash(check, (unsigned char*)public->id, 16);
if(memcmp(check, hash, crypto_hash_BYTES) == 0) {
// found one
@@ -105,7 +103,7 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd) {
if(public == NULL) {
// maybe self encryption, try secrets
pcp_key_t *s = NULL;
for(s=pcpkey_hash; s != NULL; s=(pcp_key_t*)(s->hh.next)) {
pcphash_iterate(s) {
crypto_hash(check, (unsigned char*)s->id, 16);
if(memcmp(check, hash, crypto_hash_BYTES) == 0) {
// matching secret

View File

@@ -33,6 +33,7 @@
#include "uthash.h"
#include "z85.h"
#include "keyprint.h"
#include "keyhash.h"
int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd);
int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, char *recipient);

View File

@@ -131,12 +131,12 @@ void pcp_listkeys() {
if(nkeys > 0) {
printf("Key ID Type Creation Time Owner\n");
for(k=pcpkey_hash; k != NULL; k=(pcp_key_t*)(k->hh.next)) {
pcphash_iterate(k) {
pcpkey_printlineinfo(k);
}
pcp_pubkey_t *p;
for(p=pcppubkey_hash; p != NULL; p=(pcp_pubkey_t*)(p->hh.next)) {
pcphash_iteratepub(p) {
pcppubkey_printlineinfo(p);
}
}
@@ -184,7 +184,7 @@ char *pcp_normalize_id(char *keyid) {
pcp_key_t *pcp_find_primary_secret() {
pcp_key_t *key = NULL;
pcp_key_t *k;
for(k=pcpkey_hash; k != NULL; k=(pcp_key_t*)(k->hh.next)) {
pcphash_iterate(k) {
if(k->type == PCP_KEY_TYPE_MAINSECRET) {
key = ucmalloc(sizeof(pcp_key_t));
memcpy(key, k, sizeof(pcp_key_t));
@@ -195,7 +195,7 @@ pcp_key_t *pcp_find_primary_secret() {
// no primary? whoops
int nkeys = HASH_COUNT(pcpkey_hash);
if(nkeys == 1) {
for(k=pcpkey_hash; k != NULL; k=(pcp_key_t*)(k->hh.next)) {
pcphash_iterate(k) {
key = ucmalloc(sizeof(pcp_key_t));
memcpy(key, k, sizeof(pcp_key_t));
return key;
@@ -474,7 +474,7 @@ int pcp_sanitycheck_pub(pcp_pubkey_t *key) {
return 1;
}
pcp_pubkey_t *maybe = pcppubkey_exists(key->id);
pcp_pubkey_t *maybe = pcphash_pubkeyexists(key->id);
if(maybe != NULL) {
fatal("Pubkey sanity check: there already exists a key with the id 0x%s\n", key->id);
return 1;
@@ -525,7 +525,7 @@ int pcp_sanitycheck_key(pcp_key_t *key) {
return 1;
}
pcp_key_t *maybe = pcpkey_exists(key->id);
pcp_key_t *maybe = pcphash_keyexists(key->id);
if(maybe != NULL) {
fatal("Secretkey sanity check: there already exists a key with the id 0x%s\n", key->id);
return 1;
@@ -535,7 +535,7 @@ int pcp_sanitycheck_key(pcp_key_t *key) {
}
void pcpdelete_key(char *keyid) {
pcp_pubkey_t *p = pcppubkey_exists(keyid);
pcp_pubkey_t *p = pcphash_pubkeyexists(keyid);
if(p != NULL) {
// delete public
@@ -545,7 +545,7 @@ void pcpdelete_key(char *keyid) {
fprintf(stderr, "Public key deleted.\n");
}
else {
pcp_key_t *s = pcpkey_exists(keyid);
pcp_key_t *s = pcphash_keyexists(keyid);
if(s != NULL) {
// delete secret
HASH_DEL(pcpkey_hash, s);
@@ -560,7 +560,7 @@ void pcpdelete_key(char *keyid) {
}
void pcpedit_key(char *keyid) {
pcp_key_t *key = pcpkey_exists(keyid);
pcp_key_t *key = pcphash_keyexists(keyid);
if(key != NULL) {
if(key->secret[0] == 0) {
@@ -599,7 +599,7 @@ char *pcp_find_id_byrec(char *recipient) {
pcp_pubkey_t *p;
char *id = NULL;
_lc(recipient);
for(p=pcppubkey_hash; p != NULL; p=(pcp_pubkey_t*)(p->hh.next)) {
pcphash_iteratepub(p) {
if(strncmp(p->owner, recipient, 255) == 0) {
id = ucmalloc(17);
strncpy(id, p->id, 17);

View File

@@ -37,6 +37,7 @@
#include "defines.h"
#include "readpass.h"
#include "keyprint.h"
#include "keyhash.h"
#define _WITH_GETLINE

View File

@@ -140,14 +140,14 @@ int pcptext_infile(char *infile) {
void pcptext_key(char *keyid) {
pcp_key_t *s = pcpkey_exists(keyid);
pcp_key_t *s = pcphash_keyexists(keyid);
if(s != NULL) {
if(debug)
pcp_dumpkey(s);
pcpkey_print(s, stdout);
}
else {
pcp_pubkey_t *p = pcppubkey_exists(keyid);
pcp_pubkey_t *p = pcphash_pubkeyexists(keyid);
if(p != NULL) {
if(debug)
pcp_dumppubkey(p);
@@ -431,7 +431,7 @@ void pcpexport_yaml(char *outfile) {
fprintf(out, "---\n");
fprintf(out, "secret-keys:\n");
for(s=pcpkey_hash; s != NULL; s=(pcp_key_t*)(s->hh.next)) {
pcphash_iterate(s) {
fprintf(out, " -\n");
fprintf(out, " id: %s\n", s->id);
fprintf(out, " owner: %s\n", s->owner);
@@ -456,7 +456,7 @@ void pcpexport_yaml(char *outfile) {
}
fprintf(out, "public-keys:\n");
for(p=pcppubkey_hash; p != NULL; p=(pcp_pubkey_t*)(p->hh.next)) {
pcphash_iteratepub(p) {
fprintf(out, " -\n");
fprintf(out, " id: %s\n", p->id);
fprintf(out, " owner: %s\n", p->owner);

View File

@@ -28,6 +28,7 @@
#include "vault.h"
#include "pcp.h"
#include "keymgmt.h"
#include "keyhash.h"
void pcp_dumpkey(pcp_key_t *k);
void pcp_dumppubkey(pcp_pubkey_t *k);

View File

@@ -229,7 +229,7 @@ int main (int argc, char **argv) {
}
if(usevault == 1) {
pcp_inithashes();
pcphash_init();
vault = pcpvault_init(vaultfile);
if(vault != NULL) {
switch (mode) {
@@ -396,7 +396,7 @@ int main (int argc, char **argv) {
}
}
pcpvault_close(vault);
pcp_cleanhashes();
pcphash_clean();
ucfree(vaultfile);
}
else {

View File

@@ -45,6 +45,7 @@
#include "usage.h"
#include "encryption.h"
#include "signature.h"
#include "keyhash.h"
// operation modi
// perl -e '$x=0; while ($x<100000) { $x++; $x *= 1.7; printf "0x%08X: %d\n", $x, $x }'