]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - sshdss.c
first pass
[PuTTY.git] / sshdss.c
index 5633e39545bae50393d57f73cf3f8f238afe8740..20a5e7fa61247742a8d961a2858c213a74dbbbb1 100644 (file)
--- a/sshdss.c
+++ b/sshdss.c
@@ -85,7 +85,8 @@ static Bignum get160(const char **data, int *datalen)
 
 static void dss_freekey(void *key);    /* forward reference */
 
-static void *dss_newkey(const char *data, int len)
+static void *dss_newkey(const struct ssh_signkey *self,
+                        const char *data, int len)
 {
     const char *p;
     int slen;
@@ -190,43 +191,6 @@ static char *dss_fmtkey(void *key)
     return p;
 }
 
-static char *dss_fingerprint(void *key)
-{
-    struct dss_key *dss = (struct dss_key *) key;
-    struct MD5Context md5c;
-    unsigned char digest[16], lenbuf[4];
-    char buffer[16 * 3 + 40];
-    char *ret;
-    int numlen, i;
-
-    MD5Init(&md5c);
-    MD5Update(&md5c, (unsigned char *)"\0\0\0\7ssh-dss", 11);
-
-#define ADD_BIGNUM(bignum) \
-    numlen = (bignum_bitcount(bignum)+8)/8; \
-    PUT_32BIT(lenbuf, numlen); MD5Update(&md5c, lenbuf, 4); \
-    for (i = numlen; i-- ;) { \
-        unsigned char c = bignum_byte(bignum, i); \
-        MD5Update(&md5c, &c, 1); \
-    }
-    ADD_BIGNUM(dss->p);
-    ADD_BIGNUM(dss->q);
-    ADD_BIGNUM(dss->g);
-    ADD_BIGNUM(dss->y);
-#undef ADD_BIGNUM
-
-    MD5Final(digest, &md5c);
-
-    sprintf(buffer, "ssh-dss %d ", bignum_bitcount(dss->p));
-    for (i = 0; i < 16; i++)
-       sprintf(buffer + strlen(buffer), "%s%02x", i ? ":" : "",
-               digest[i]);
-    ret = snewn(strlen(buffer) + 1, char);
-    if (ret)
-       strcpy(ret, buffer);
-    return ret;
-}
-
 static int dss_verifysig(void *key, const char *sig, int siglen,
                         const char *data, int datalen)
 {
@@ -403,7 +367,8 @@ static unsigned char *dss_private_blob(void *key, int *len)
     return blob;
 }
 
-static void *dss_createkey(const unsigned char *pub_blob, int pub_len,
+static void *dss_createkey(const struct ssh_signkey *self,
+                           const unsigned char *pub_blob, int pub_len,
                           const unsigned char *priv_blob, int priv_len)
 {
     struct dss_key *dss;
@@ -414,7 +379,7 @@ static void *dss_createkey(const unsigned char *pub_blob, int pub_len,
     unsigned char digest[20];
     Bignum ytest;
 
-    dss = dss_newkey((char *) pub_blob, pub_len);
+    dss = dss_newkey(self, (char *) pub_blob, pub_len);
     if (!dss)
         return NULL;
     dss->x = getmp(&pb, &priv_len);
@@ -454,7 +419,8 @@ static void *dss_createkey(const unsigned char *pub_blob, int pub_len,
     return dss;
 }
 
-static void *dss_openssh_createkey(const unsigned char **blob, int *len)
+static void *dss_openssh_createkey(const struct ssh_signkey *self,
+                                   const unsigned char **blob, int *len)
 {
     const char **b = (const char **) blob;
     struct dss_key *dss;
@@ -505,12 +471,13 @@ static int dss_openssh_fmtkey(void *key, unsigned char *blob, int len)
     return bloblen;
 }
 
-static int dss_pubkey_bits(const void *blob, int len)
+static int dss_pubkey_bits(const struct ssh_signkey *self,
+                           const void *blob, int len)
 {
     struct dss_key *dss;
     int ret;
 
-    dss = dss_newkey((const char *) blob, len);
+    dss = dss_newkey(self, (const char *) blob, len);
     if (!dss)
         return -1;
     ret = bignum_bitcount(dss->p);
@@ -705,9 +672,9 @@ const struct ssh_signkey ssh_dss = {
     dss_openssh_fmtkey,
     5 /* p,q,g,y,x */,
     dss_pubkey_bits,
-    dss_fingerprint,
     dss_verifysig,
     dss_sign,
     "ssh-dss",
-    "dss"
+    "dss",
+    NULL,
 };