aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/misc.c')
-rw-r--r--g10/misc.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 5c3ef12de..2f8d28af7 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -550,3 +550,28 @@ pct_expando(const char *string,PKT_public_key *pk)
m_free(ret);
return NULL;
}
+
+int
+hextobyte( const char *s )
+{
+ int c;
+
+ if( *s >= '0' && *s <= '9' )
+ c = 16 * (*s - '0');
+ else if( *s >= 'A' && *s <= 'F' )
+ c = 16 * (10 + *s - 'A');
+ else if( *s >= 'a' && *s <= 'f' )
+ c = 16 * (10 + *s - 'a');
+ else
+ return -1;
+ s++;
+ if( *s >= '0' && *s <= '9' )
+ c += *s - '0';
+ else if( *s >= 'A' && *s <= 'F' )
+ c += 10 + *s - 'A';
+ else if( *s >= 'a' && *s <= 'f' )
+ c += 10 + *s - 'a';
+ else
+ return -1;
+ return c;
+}