Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <linux/input.h>
#include <event.h>
import sys, hashlib
for line in file(sys.argv[2]):
if hashlib.md5(line.rstrip()).hexdigest() == sys.argv[1]: print line,
if (s->servername_done == 0) {
switch (servname_type) {
case TLSEXT_NAMETYPE_host_name:
if (s->session->tlsext_hostname == NULL) {
if (len > TLSEXT_MAXLEN_host_name ||
((s->session->tlsext_hostname = OPENSSL_malloc(len + 1)) == NULL)) {
*al = TLS1_AD_UNRECOGNIZED_NAME;
return 0;
}
memcpy(s->session->tlsext_hostname, sdata, len);
pthread_mutex_t *thread_locks;
unsigned long
openssl_thread_id(void) {
return (unsigned long) pthread_self();
}
void
openssl_thread_lock( int mode, int lock_id, const char* file, int line ) {
if ( mode & CRYPTO_LOCK )
int ssl3_get_client_hello(SSL *s) {
/* bunch of crap here */
/* remember, ssl_get_prev_session properly locks s->session */
i = ssl_get_prev_session(s, p, j, d + n);
if (i == 1) { /* previous session */
s->hit=1;
}
}
@errzey
errzey / davehull.sh
Created April 20, 2011 20:10
Example script to show how to do an intelligent merge-sort in parallel
#!/bin/bash
# determines number of proccessors, splits a large file into sizes that
# can be consumed by n-1 sort processes (where n is the number of processors)
#
# After the file has been split up properly, it will run a sort on each split
# file in parallel. Once all processes have completed, a merge sort is executed.
#
# mthomas@n2o:~/words [100%] $ du -h big
# 1.7G big
@errzey
errzey / mperf.c
Created May 9, 2011 16:34
method mperf testing
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <time.h>
#include <inttypes.h>
enum evhttp_cmd_type {
EVHTTP_REQ_GET = 1 << 0,
@errzey
errzey / gist:1038677
Created June 21, 2011 19:34
apache bench (ab) + ssl3 session-ID support
/* usage: openssl s_client -connect localhost:8081 -sess_out outfile -ssl3 */
/* ab -I outfile ... */
--- support/ab.c 2010-07-12 05:26:29.000000000 -0400
+++ support/ab.c 2011-06-21 15:29:21.961972191 -0400
@@ -340,6 +340,7 @@
char *ssl_cipher = NULL;
char *ssl_info = NULL;
BIO *bio_out,*bio_err;
+char * sess_in = NULL;
#endif
@errzey
errzey / gist:1057035
Created June 30, 2011 19:43
Evbuffer Profile
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <time.h>
#include <event.h>
static void
test_evbuffers(int iter) {
@errzey
errzey / gist:1059030
Created July 1, 2011 17:34
one way to keep bufferevent pairs active.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <event.h>
struct _targs {
struct bufferevent ** pair;
struct event * ev;