aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-11-17 00:34:14 +0100
committerGravatar Tom Willemse2013-11-17 00:34:14 +0100
commit6e7e8e9ba249bb8fac1d90e2c9a9628563232c1e (patch)
treeccf3cf6bc04ceb47eb2e82b4c5c684adc126e570
parent9b4461479e0f038391367e5afca1735b7e11c788 (diff)
downloadlibdispass-6e7e8e9ba249bb8fac1d90e2c9a9628563232c1e.tar.gz
libdispass-6e7e8e9ba249bb8fac1d90e2c9a9628563232c1e.zip
Remove = from generated passphrase
-rw-r--r--sha1.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sha1.c b/sha1.c
index 7e988b2..5198a19 100644
--- a/sha1.c
+++ b/sha1.c
@@ -46,6 +46,30 @@ sha512_to_string(unsigned char *data, char *buff)
}
}
+void
+rmchar(char rm, char **s)
+{
+ int i, j = 0;
+ char *new;
+ size_t len;
+
+ if (!strchr(*s, rm))
+ return;
+
+ len = strlen(*s);
+ new = calloc(len + 1, sizeof(char));
+
+ for (i = 0; i < len; i++) {
+ char c;
+
+ if ((c = (*s)[i]) != rm)
+ new[j++] = c;
+ }
+
+ strncpy(*s, new, len);
+ free(new);
+}
+
char *
dispass1(char *label, char *password, int len, int seqno)
{
@@ -63,6 +87,7 @@ dispass1(char *label, char *password, int len, int seqno)
sha512_to_string(d, buff);
b64 = base64encode(buff, strlen(buff));
b64[MIN(len, MAXLEN)] = '\0';
+ rmchar('=', &b64);
return b64;
}
@@ -87,6 +112,7 @@ dispass2(char *label, char *password, int len, int seqno)
sha512_to_string(d, buff);
b64 = base64encode(buff, strlen(buff));
b64[MIN(len, MAXLEN)] = '\0';
+ rmchar('=', &b64);
return b64;
}