Skip to content

Instantly share code, notes, and snippets.

View mafrasi2's full-sized avatar

Max Sistemich mafrasi2

  • Germany
View GitHub Profile
/*
* Compile with -lxcb -lxcb-randr
*/
#include <stdio.h>
#include <stdlib.h>
#include <xcb/xcb.h>
#include <xcb/randr.h>
int main() {
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();
// 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...
}
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;
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)))