Skip to content

Instantly share code, notes, and snippets.

/*
* Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://www.openssl.org/source/license.html
* or in the file LICENSE in the source distribution.
*/
from sympy import randprime
from math import isqrt
def run(i):
t5=isqrt(i)
t=(isqrt(isqrt(i*2065)*2)*128+3)
t2=t-(isqrt(t)**2)
t3=((t*16+t2)*128+t2)*8
t=t3+t5
t4=t3-(isqrt(t3)**2)
#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <openssl/bn.h>
#if 1 /* Taken from OpenSSL */
#define BN_MASK2 (0xffffffffffffffffLL)
BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
#include <openssl/bn.h>
int main(void)
{
BIGNUM* base = BN_new();
BIGNUM* exp = BN_new();
BIGNUM* mod = BN_new();
BIGNUM* res = BN_new();
BN_CTX* ctx = BN_CTX_new();
BN_dec2bn(&base, "20602718629153394716678609007360754677019714782193251481833419525142182531659985037375070145510293237451017584368188091022126870685458069386237266432");
hello = "\x16\x03\x0b\x00\x58\x02\x00\x00\x54\x03\x03\xcf\x21\xad\x74\xe5\x9a\x61\x11\xbe\x1d\x8c\x02\x1e\x65\xb8\x91\xc2\xa2\x11\x16\x7a\xbb\x8c\x5e\x07\x9e\x09\xe2\xc8\xa8\x33\x9c\x20\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x13\x01\x00\x00\x0c\x00\x2b\x00\x02\x03\x04\x00\x33\x00\x02\x01\x03\x16\x03\x0b\x00\x58\x02\x00\x00\x54\x03\x03\xcf\x21\xad\x74\xe5\x9a\x61\x11\xbe\x1d\x8c\x02\x1e\x65\xb8\x91\xc2\xa2\x11\x16\x7a\xbb\x8c\x5e\x07\x9e\x09\xe2\xc8\xa8\x33\x9c\x20\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x13\x01\x00\x00\x0c\x00\x2b\x00\x02\x03\x04\x00\x33\x00\x02\x01\x04"
header = "\x16\x03\x0b\x00\x58\x02\x00\x00\x54\x03\x03\xcf\x21\xad\x74\xe5\x9a\x61\x11\xbe\x1d\x8c\x02\x1e\x65\xb8\x91\xc2\xa2\x11\x16\x7a\xbb\x8c\x5e\x07\x9e\x09\xe2\xc8\xa8\x33\x9c\x20\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x1
#include <fuzzing/datasource/datasource.hpp>
#include <stdexcept>
#include <optional>
#include <string>
#include <iostream>
extern "C" {
#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/integer.h>
/* Compile:
export CC=clang
git clone --depth 1 https://github.com/microsoft/SymCrypt.git
cd SymCrypt/
# Unittests don't build with clang and are not needed anyway
sed -i "s/^add_subdirectory(unittest)$//g" CMakeLists.txt
mkdir b/
cd b/
#define CF_CHECK_EQ(expr, res) if ( (expr) != (res) ) { goto end; }
#define CF_CHECK_NE(expr, res) if ( (expr) == (res) ) { goto end; }
void SymCryptFatal(UINT32 fatalCode) {
(void)fatalCode;
abort();
}
void SymCryptInjectError( PBYTE pbData, SIZE_T cbData ) {
(void)pbData;
#!/bin/bash
export CC="clang"
export CXX="clang++"
export CFLAGS="-fsanitize=fuzzer-no-link -g -O3 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
export CXXFLAGS="-fsanitize=fuzzer-no-link -g -O3 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
# Alternatively:
#export CFLAGS="-fsanitize=fuzzer-no-link -g -O3 -fsanitize=address -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
@guidovranken
guidovranken / libressl.sh
Created July 28, 2020 17:00
LibreSSL BN_nist_mod_384 undefined behavior
#!/bin/bash
set -e
export CFLAGS="-fsanitize=object-size -fno-sanitize-recover=object-size"
export CC=clang
git clone --depth 1 https://github.com/libressl-portable/portable libressl
cd libressl
./update.sh