aboutsummaryrefslogtreecommitdiff
path: root/src/lib/crypt_ops/crypto_rsa.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-07-11 13:51:26 -0400
committerNick Mathewson <nickm@torproject.org>2018-07-11 13:51:26 -0400
commit8e2df9886003c12b0624c54b950090c8fc36396b (patch)
treef5dbd0162de3d744b3cc71c50e636547b7bb165a /src/lib/crypt_ops/crypto_rsa.c
parent12a1ada15853f0cde2839921bf413ba24a741192 (diff)
downloadtor-8e2df9886003c12b0624c54b950090c8fc36396b.tar.gz
tor-8e2df9886003c12b0624c54b950090c8fc36396b.zip
Move crypto_add_spaces_to_fp() to crypto_rsa.c
Diffstat (limited to 'src/lib/crypt_ops/crypto_rsa.c')
-rw-r--r--src/lib/crypt_ops/crypto_rsa.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/crypt_ops/crypto_rsa.c b/src/lib/crypt_ops/crypto_rsa.c
index 5ec69d7319..f0fd6d5f4b 100644
--- a/src/lib/crypt_ops/crypto_rsa.c
+++ b/src/lib/crypt_ops/crypto_rsa.c
@@ -976,6 +976,26 @@ crypto_pk_get_hashed_fingerprint(crypto_pk_t *pk, char *fp_out)
return 0;
}
+/** Copy <b>in</b> to the <b>outlen</b>-byte buffer <b>out</b>, adding spaces
+ * every four characters. */
+void
+crypto_add_spaces_to_fp(char *out, size_t outlen, const char *in)
+{
+ int n = 0;
+ char *end = out+outlen;
+ tor_assert(outlen < SIZE_T_CEILING);
+
+ while (*in && out<end) {
+ *out++ = *in++;
+ if (++n == 4 && *in && out<end) {
+ n = 0;
+ *out++ = ' ';
+ }
+ }
+ tor_assert(out<end);
+ *out = '\0';
+}
+
/** Check a siglen-byte long signature at <b>sig</b> against
* <b>datalen</b> bytes of data at <b>data</b>, using the public key
* in <b>env</b>. Return 0 if <b>sig</b> is a correct signature for