projects
/
umurmur.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
618b6b3
)
More hash stuff fixes
author
Martin Johansson
<martin@fatbob.nu>
Sat, 25 Feb 2012 00:12:02 +0000
(
01:12
+0100)
committer
Martin Johansson
<martin@fatbob.nu>
Sat, 25 Feb 2012 00:12:02 +0000
(
01:12
+0100)
src/ssl.c
patch
|
blob
|
history
src/ssl.h
patch
|
blob
|
history
diff --git
a/src/ssl.c
b/src/ssl.c
index d2ef7610dbfdddb2a1ae116fda037d1384eb2188..964d7eece5d1af2b982a8cd29e0bd2395f1324b3 100644
(file)
--- a/
src/ssl.c
+++ b/
src/ssl.c
@@
-168,14
+168,15
@@
void SSLi_deinit(void)
}
/* Create SHA1 of last certificate in the peer's chain. */
}
/* Create SHA1 of last certificate in the peer's chain. */
-
void
SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash)
+
bool_t
SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash)
{
x509_cert *cert = ssl->peer_cert;
if (!ssl->peer_cert) {
/* XXX what to do? */
{
x509_cert *cert = ssl->peer_cert;
if (!ssl->peer_cert) {
/* XXX what to do? */
- return;
+ return
false
;
}
sha1(cert->raw.p, cert->raw.len, hash);
}
sha1(cert->raw.p, cert->raw.len, hash);
+ return true;
}
SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready)
}
SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready)
@@
-607,7
+608,7
@@
SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready)
}
/* Create SHA1 of last certificate in the peer's chain. */
}
/* Create SHA1 of last certificate in the peer's chain. */
-
void
SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash)
+
bool_t
SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash)
{
X509 *x509;
uint8_t *buf, *p;
{
X509 *x509;
uint8_t *buf, *p;
@@
-615,8
+616,7
@@
void SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash)
x509 = SSL_get_peer_certificate(ssl);
if (x509) {
x509 = SSL_get_peer_certificate(ssl);
if (x509) {
- /* XXX what to do? */
- return;
+ return false;
}
len = i2d_X509(x509, NULL);
}
len = i2d_X509(x509, NULL);
@@
-629,6
+629,7
@@
void SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash)
SHA1(p, len, hash);
free(buf);
SHA1(p, len, hash);
free(buf);
+ return true;
}
void SSLi_closeconnection(SSL_handle_t *ssl)
}
void SSLi_closeconnection(SSL_handle_t *ssl)
diff --git
a/src/ssl.h
b/src/ssl.h
index 6aa0b1ae654c2bf8edef9e3e819b416746e7b449..f5fa4a8229f9c8ee84d22dcb7792a28d6d5ffa92 100644
(file)
--- a/
src/ssl.h
+++ b/
src/ssl.h
@@
-108,7
+108,7
@@
typedef SSL SSL_handle_t;
void SSLi_init(void);
void SSLi_deinit(void);
SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready);
void SSLi_init(void);
void SSLi_deinit(void);
SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready);
-
void
SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash);
+
bool_t
SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash);
void SSLi_closeconnection(SSL_handle_t *ssl);
int SSLi_nonblockaccept(SSL_handle_t *ssl, bool_t *SSLready);
int SSLi_read(SSL_handle_t *ssl, uint8_t *buf, int len);
void SSLi_closeconnection(SSL_handle_t *ssl);
int SSLi_nonblockaccept(SSL_handle_t *ssl, bool_t *SSLready);
int SSLi_read(SSL_handle_t *ssl, uint8_t *buf, int len);
@@
-118,4
+118,10
@@
bool_t SSLi_data_pending(SSL_handle_t *ssl);
void SSLi_shutdown(SSL_handle_t *ssl);
void SSLi_free(SSL_handle_t *ssl);
void SSLi_shutdown(SSL_handle_t *ssl);
void SSLi_free(SSL_handle_t *ssl);
+static inline void SSLi_hash2hex(uint8_t *hash, char *out)
+{
+ int i, offset = 0;
+ for (i = 0; i < 20; i++)
+ offset += sprintf(out + offset, "%02x", hash[i]);
+}
#endif
#endif