This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
from itertools import count, islice, zip_longest | |
import sys | |
from pprint import pprint | |
def isPrime(n): | |
if n < 2: return False | |
return all(n%i for i in islice(count(2), int(sqrt(n)-1))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VersionExchangeParser { | |
VersionExchangeState state; | |
uint16_t num_versions = 0; | |
uint16_t current_version = 0; | |
vector<Version> versions; | |
LengthDecoder aes_key_length_decoder; | |
length_t aes_key_length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sämtliche Datentypen, die in der Struktur vorkommen, implementieren das hier. | |
// parseDER wird immer mit den Daten für exakt dieses Objekt aufgerufen. | |
abstract class ASN1Object { | |
abstract static ASN1Object parseDER(bytevector_t data); | |
}; | |
class ASN1Integer extends ASN1Object { | |
bytevector data; // oder mpz_class etc. | |
static ASN1Integer parseDER... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bytevector_t data = receive(1024); | |
ASN1Structure dh_params = ASN1Structure::parseDER(dat); | |
// dh_params[0] ist die Sequence und dh_params[0][0] ist das | |
// 0te Element der Sequence, also der ASN1Integer p | |
mpz_class p = dh_params[0][0].get_mpz(); | |
mpz_class g = dh_params[0][1].get_mpz(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Compile with -lxcb -lxcb-randr | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <xcb/xcb.h> | |
#include <xcb/randr.h> | |
int main() { |