[or-cvs] Remove DER64 functions in trunk: they will never be used ag...
Nick Mathewson
nickm at seul.org
Mon Apr 10 21:23:02 UTC 2006
Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv7560/src/common
Modified Files:
crypto.c crypto.h
Log Message:
Remove DER64 functions in trunk: they will never be used again unless the directory authorities switch back to 0.0.9tooearly.
Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/crypto.c,v
retrieving revision 1.189
retrieving revision 1.190
diff -u -p -d -r1.189 -r1.190
--- crypto.c 26 Mar 2006 06:47:51 -0000 1.189
+++ crypto.c 10 Apr 2006 21:22:59 -0000 1.190
@@ -574,70 +574,6 @@ crypto_pk_write_private_key_to_filename(
return r;
}
-/** Allocate a new string in *<b>out</b>, containing the public portion of the
- * RSA key in <b>env</b>, encoded first with DER, then in base-64. Return the
- * length of the encoded representation on success, and -1 on failure.
- *
- * <i>This function is for temporary use only. We need a simple
- * one-line representation for keys to work around a bug in parsing
- * directories containing "opt keyword\n-----BEGIN OBJECT----" entries
- * in versions of Tor up to 0.0.9pre2.</i>
- */
-int
-crypto_pk_DER64_encode_public_key(crypto_pk_env_t *env, char **out)
-{
- int len;
- char buf[PK_BYTES*2]; /* Too long, but hey, stacks are big. */
- tor_assert(env);
- tor_assert(out);
- len = crypto_pk_asn1_encode(env, buf, sizeof(buf));
- if (len < 0) {
- return -1;
- }
- *out = tor_malloc(len * 2); /* too long, but safe. */
- if (base64_encode(*out, len*2, buf, len) < 0) {
- log_warn(LD_CRYPTO, "Error base64-encoding DER-encoded key");
- tor_free(*out);
- return -1;
- }
- /* Remove spaces */
- tor_strstrip(*out, " \r\n\t");
- return strlen(*out);
-}
-
-/** Decode a base-64 encoded DER representation of an RSA key from <b>in</b>,
- * and store the result in <b>env</b>. Return 0 on success, -1 on failure.
- *
- * <i>This function is for temporary use only. We need a simple
- * one-line representation for keys to work around a bug in parsing
- * directories containing "opt keyword\n-----BEGIN OBJECT----" entries
- * in versions of Tor up to 0.0.9pre2.</i>
- */
-crypto_pk_env_t *
-crypto_pk_DER64_decode_public_key(const char *in)
-{
- char partitioned[PK_BYTES*2 + 16];
- char buf[PK_BYTES*2];
- int len;
- tor_assert(in);
- len = strlen(in);
-
- if (strlen(in) > PK_BYTES*2) {
- return NULL;
- }
- /* base64_decode doesn't work unless we insert linebreaks every 64
- * characters. how dumb. */
- if (tor_strpartition(partitioned, sizeof(partitioned), in, "\n", 64,
- ALWAYS_TERMINATE))
- return NULL;
- len = base64_decode(buf, sizeof(buf), partitioned, strlen(partitioned));
- if (len<0) {
- log_warn(LD_CRYPTO,"Error base-64 decoding key");
- return NULL;
- }
- return crypto_pk_asn1_decode(buf, len);
-}
-
/** Return true iff <b>env</b> has a valid key.
*/
int
Index: crypto.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/crypto.h,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -p -d -r1.79 -r1.80
--- crypto.h 26 Mar 2006 06:47:51 -0000 1.79
+++ crypto.h 10 Apr 2006 21:22:59 -0000 1.80
@@ -79,8 +79,6 @@ int crypto_pk_read_public_key_from_strin
const char *src, size_t len);
int crypto_pk_write_private_key_to_filename(crypto_pk_env_t *env,
const char *fname);
-int crypto_pk_DER64_encode_public_key(crypto_pk_env_t *env, char **dest);
-crypto_pk_env_t *crypto_pk_DER64_decode_public_key(const char *in);
int crypto_pk_check_key(crypto_pk_env_t *env);
int crypto_pk_cmp_keys(crypto_pk_env_t *a, crypto_pk_env_t *b);
More information about the tor-commits
mailing list