diff options
author | Tom Willemse | 2013-11-17 00:34:14 +0100 |
---|---|---|
committer | Tom Willemse | 2013-11-17 00:34:14 +0100 |
commit | 6e7e8e9ba249bb8fac1d90e2c9a9628563232c1e (patch) | |
tree | ccf3cf6bc04ceb47eb2e82b4c5c684adc126e570 | |
parent | 9b4461479e0f038391367e5afca1735b7e11c788 (diff) | |
download | libdispass-6e7e8e9ba249bb8fac1d90e2c9a9628563232c1e.tar.gz libdispass-6e7e8e9ba249bb8fac1d90e2c9a9628563232c1e.zip |
Remove = from generated passphrase
-rw-r--r-- | sha1.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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; } |