}
/* 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? */
- return;
+ return false;
}
sha1(cert->raw.p, cert->raw.len, hash);
+ return true;
}
SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready)
}
/* 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 = SSL_get_peer_certificate(ssl);
if (x509) {
- /* XXX what to do? */
- return;
+ return false;
}
len = i2d_X509(x509, NULL);
SHA1(p, len, hash);
free(buf);
+ return true;
}
void SSLi_closeconnection(SSL_handle_t *ssl)
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_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