Merge branch 'next/kelvin/411' into yu/stun

This commit is contained in:
yosoyubik 2023-12-06 13:33:56 +01:00
commit 32843ba32c
60 changed files with 583 additions and 2238 deletions

View File

@ -38,7 +38,11 @@ jobs:
- name: Install toolchains
if: steps.build-cache.outputs.cache-hit != 'true'
run: bazel run //bazel/toolchain:x86_64-linux-musl-gcc
run: |
bazel run //bazel/toolchain:x86_64-linux-musl-gcc
- name: Install dependencies
run: sudo apt-get install -y autoconf-archive
- name: Set pace
run: echo "${{ inputs.pace }}" > ./PACE

View File

@ -43,7 +43,7 @@ jobs:
# runner with BuildJet instead.
- { target: linux-aarch64, runner: buildjet-2vcpu-ubuntu-2204-arm }
- { target: linux-x86_64, runner: ubuntu-22.04 }
# GitHub doesn't provide macOS machines with Apple Silicon, so we
# GitHub doesn't provide macOS machines with Apple Silicon, so we
# self-host a runner with MacStadium instead.
- { target: macos-aarch64, runner: [self-hosted, macos, ARM64] }
- { target: macos-x86_64, runner: macos-12 }
@ -72,7 +72,7 @@ jobs:
/private/var/tmp/_bazel_$(whoami)
# Cache musl libc toolchains.
/usr/local/*-musl
- name: chown /usr/local/*-musl
if: ${{ matrix.target == 'linux-x86_64' || matrix.target == 'linux-aarch64'}}
run: |
@ -113,17 +113,20 @@ jobs:
run: |
case "${{ matrix.target }}" in
"linux-aarch64")
sudo apt-get -y install autoconf-archive
bazel run //bazel/toolchain:aarch64-linux-musl-gcc
;;
"linux-x86_64")
sudo apt-get -y install autoconf-archive
bazel run //bazel/toolchain:x86_64-linux-musl-gcc
;;
"macos-aarch64")
brew install pkg-config autoconf-archive
;;
"macos-x86_64")
# Switch Xcode path to match the path specified in our bazel toolchain.
sudo xcode-select --switch /Library/Developer/CommandLineTools
brew install automake libtool llvm@15
brew install automake autoconf-archive libtool llvm@15
;;
*)
echo "Unsupported target: ${{ matrix.target }}"

View File

@ -50,7 +50,7 @@ This will take a few minutes.
### macOS
After installing `automake` and `libtool`, you're ready to build Vere.
After installing `automake`, `autoconf-archive`, `pkg-config`, and `libtool`, you're ready to build Vere.
## Build Commands

View File

@ -19,8 +19,6 @@ defined in its own package:
- [`pkg/c3`](pkg/c3): A set of basic utilities for writing Urbit's style of C.
- [`pkg/ent`](pkg/ent): A cross-platform wrapper for `getentropy(2)`.
- [`pkg/urcrypt`](pkg/urcrypt): A standardized interface for calling various
cryptographic functions used in the Urbit runtime.
- [`pkg/ur`](pkg/ur): An implementation of [jam][jam] and [cue][cue], Urbit's
bitwise noun serialization and deserialization algorithms, respectively.
- [`pkg/noun`](pkg/noun): The Nock virtual machine and snapshotting system.

View File

@ -121,15 +121,6 @@ versioned_http_archive(
version = "9681279cfaa6e6399bb7ca3afbbc27fc2e19df4b",
)
versioned_http_archive(
name = "argon2",
build_file = "//bazel/third_party/argon2:argon2.BUILD",
sha256 = "40850e6e6324be10f14228d17b617ad2074bb926eeddd6fe40ad5df833833949",
strip_prefix = "argon2-{version}",
url = "https://github.com/urbit/argon2/archive/{version}.tar.gz",
version = "a4c1e3f7138c2e577376beb99f964cf71e1c8b1b",
)
versioned_http_archive(
name = "bazel_gazelle",
sha256 = "efbbba6ac1a4fd342d5122cbdfdb82aeb2cf2862e35022c752eaddffada7c3f3",
@ -154,15 +145,6 @@ versioned_http_archive(
version = "7.85.0",
)
versioned_http_archive(
name = "ed25519",
build_file = "//bazel/third_party/ed25519:ed25519.BUILD",
sha256 = "373923c85f61276e3cad2c0ae7a5d5cd4809ffe46c5abc1dc8276683a55782a0",
strip_prefix = "ed25519-{version}",
url = "https://github.com/orlp/ed25519/archive/{version}.tar.gz",
version = "7fa6712ef5d581a6981ec2b08ee623314cd1d1c4",
)
versioned_http_archive(
name = "gmp",
build_file = "//bazel/third_party/gmp:gmp.BUILD",
@ -214,17 +196,6 @@ versioned_http_file(
version = "255fb1ca8206072f1d09425f0db61ecfe7ff5b17",
)
versioned_http_archive(
name = "keccak_tiny",
build_file = "//bazel/third_party/keccak_tiny:keccak_tiny.BUILD",
patch_args = ["-p1"],
patches = ["//bazel/third_party/keccak_tiny:{version}.patch"],
sha256 = "6d4717f96b84805886c74bad89e911076664d992f197634fd7cdfca2ac0f62ef",
strip_prefix = "keccak-tiny-{version}",
url = "https://github.com/coruus/keccak-tiny/archive/{version}.tar.gz",
version = "64b6647514212b76ae7bca0dea9b7b197d1d8186",
)
versioned_http_archive(
name = "lmdb",
build_file = "//bazel/third_party/lmdb:lmdb.BUILD",
@ -272,18 +243,6 @@ versioned_http_archive(
version = "67108d883061043e55d0fb13961ac1b6fc8a485c",
)
versioned_http_archive(
name = "scrypt",
build_file = "//bazel/third_party/scrypt:scrypt.BUILD",
sha256 = "df681fb19b653b1a12970ebb6091bb2b58411b9e7baf01143870f6be3f099541",
strip_prefix = "libscrypt-{version}",
url = "https://github.com/technion/libscrypt/archive/{version}.tar.gz",
# When bumping the version, compare `Makefile` in the `scrypt` repo to
# {build_file} and confirm that {build_file} remains an accurate description
# of the scrypt build process.
version = "60e585cdd752262b22ed4113eca41c0461a61608",
)
versioned_http_archive(
name = "secp256k1",
build_file = "//bazel/third_party/secp256k1:secp256k1.BUILD",
@ -337,6 +296,15 @@ versioned_http_file(
version = "ea8fee3aa0434d4bdf1bf785e5ec346c7ecba7fd",
)
versioned_http_archive(
name = "urcrypt",
build_file = "//bazel/third_party/urcrypt:urcrypt.BUILD",
sha256 = "afc1182e10eeebaeb2a111c2bd889747792d255e26aba7fdcd6751d0d3c2bb35",
strip_prefix = "urcrypt-{version}",
url = "https://github.com/urbit/urcrypt/archive/{version}.tar.gz",
version = "43479c3262a11e20da5f6218f3b0b3d63931ceea",
)
versioned_http_archive(
name = "uv",
build_file = "//bazel/third_party/uv:uv.BUILD",

View File

@ -11,7 +11,6 @@ refresh_compile_commands(
"//pkg/ent",
"//pkg/noun",
"//pkg/ur",
"//pkg/urcrypt",
"//pkg/vere:urbit",
],
# No need to add flags already in .bazelrc. They're automatically picked up.
@ -19,4 +18,4 @@ refresh_compile_commands(
# Wildcard patterns, like //... for everything, *are* allowed here, just like a build.
# As are additional targets (+) and subtractions (-), like in bazel query https://docs.bazel.build/versions/main/query.html#expressions
# And if you're working on a header-only library, specify a test or binary target that compiles it.
)
)

0
bazel/third_party/urcrypt/BUILD.bazel vendored Normal file
View File

28
bazel/third_party/urcrypt/urcrypt.BUILD vendored Normal file
View File

@ -0,0 +1,28 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
filegroup(
name = "all",
srcs = glob(["**"]),
)
configure_make(
name = "urcrypt",
autogen = True,
configure_in_place = True,
configure_options = [
"--disable-shared",
],
copts = [
"-Wall",
"-g",
"-O3",
],
deps = [
"@aes_siv",
"@openssl",
"@secp256k1"
],
lib_source = ":all",
out_static_libs = ["liburcrypt.a"],
visibility = ["//visibility:public"],
)

View File

@ -33,13 +33,13 @@ vere_library(
"//pkg/c3",
"//pkg/ent",
"//pkg/ur",
"//pkg/urcrypt",
"@gmp",
"@murmur3",
"@openssl",
"@pdjson",
"@sigsegv",
"@softfloat",
"@urcrypt",
] + select({
"@platforms//os:macos": ["//pkg/noun/platform/darwin"],
"@platforms//os:linux": ["//pkg/noun/platform/linux"],

View File

@ -898,6 +898,31 @@ u3h_take(u3p(u3h_root) har_p)
return u3h_take_with(har_p, u3a_take);
}
/* _ch_take_uni_cb(): take a key/value pair, put into [dst_p].
*/
static void
_ch_take_uni_cb(u3_cell kev, void* wit)
{
u3a_cell* kev_u = u3a_to_ptr(kev);
u3_noun key = u3a_take(kev_u->hed);
u3_noun val = u3a_take(kev_u->tel);
{
u3p(u3h_root) dst_p = *(u3p(u3h_root)*)wit;
u3h_put(dst_p, key, val);
}
u3z(key);
}
/* u3h_take_uni(): take entries from [src_p], put into [dst_p].
*/
void
u3h_take_uni(u3p(u3h_root) dst_p, u3p(u3h_root) src_p)
{
u3h_walk_with(src_p, _ch_take_uni_cb, &dst_p);
}
/* _ch_mark_buck(): mark bucket for gc.
*/
c3_w

View File

@ -179,6 +179,11 @@
u3p(u3h_root)
u3h_take(u3p(u3h_root) har_p);
/* u3h_take_uni(): take entries from [src_p], put into [dst_p].
*/
void
u3h_take_uni(u3p(u3h_root) dst_p, u3p(u3h_root) src_p);
/* u3h_wyt(): number of entries
*/
c3_w

View File

@ -149,6 +149,21 @@ u3i_slab_from(u3i_slab* sab_u, u3_atom a, c3_g met_g, c3_d len_d)
// copies [a], zero-initializes any additional space
//
u3r_words(0, sab_u->len_w, sab_u->buf_w, a);
// if necessary, mask off extra most-significant bits
// from most-significant word
//
if ( (5 > met_g) && (u3r_met(5, a) >= sab_u->len_w) ) {
// NB: overflow already checked in _ci_slab_size()
//
c3_d bit_d = len_d << met_g;
c3_w wor_w = bit_d >> 5;
c3_w bit_w = bit_d & 0x1f;
if ( bit_w ) {
sab_u->buf_w[wor_w] &= ((c3_w)1 << bit_w) - 1;
}
}
}
/* u3i_slab_grow(): resize slab, zero-initializing new space.
@ -595,133 +610,6 @@ u3i_list(u3_weak som, ...)
return u3kb_flop(lit);
}
static u3_noun
_edit_cat(u3_noun big, c3_l axe_l, u3_noun som)
{
if ( c3n == u3du(big) ) {
return u3m_bail(c3__exit);
}
else {
u3_noun pro;
switch ( axe_l ) {
case 2:
pro = u3nc(som, u3k(u3t(big)));
break;
case 3:
pro = u3nc(u3k(u3h(big)), som);
break;
default: {
c3_l mor_l = u3x_mas(axe_l);
pro = ( 2 == u3x_cap(axe_l) )
? u3nc(_edit_cat(u3k(u3h(big)), mor_l, som), u3k(u3t(big)))
: u3nc(u3k(u3h(big)), _edit_cat(u3k(u3t(big)), mor_l, som));
break;
}
}
u3z(big);
return pro;
}
}
static u3_noun
_edit(u3_noun big, u3_noun axe, u3_noun som)
{
if ( c3y == u3a_is_cat(axe) ) {
return _edit_cat(big, (c3_l) axe, som);
}
else if ( c3n == u3du(big) ) {
return u3m_bail(c3__exit);
}
else {
u3_noun mor = u3qc_mas(axe),
pro = ( 2 == u3qc_cap(axe) )
? u3nc(_edit(u3k(u3h(big)), mor, som), u3k(u3t(big)))
: u3nc(u3k(u3h(big)), _edit(u3k(u3t(big)), mor, som));
u3z(mor);
u3z(big);
return pro;
}
}
static u3_noun _edit_or_mutate_cat(u3_noun, c3_l, u3_noun);
static u3_noun _edit_or_mutate(u3_noun, u3_noun, u3_noun);
static void
_mutate_cat(u3_noun big, c3_l axe_l, u3_noun som)
{
if ( c3n == u3du(big) ) {
u3m_bail(c3__exit);
}
else {
u3a_cell* cel_u = (void*) u3a_to_ptr(big);
switch ( axe_l ) {
case 2:
u3z(cel_u->hed);
cel_u->hed = som;
break;
case 3:
u3z(cel_u->tel);
cel_u->tel = som;
break;
default: {
u3_noun* tar = ( 2 == u3x_cap(axe_l) )
? &(cel_u->hed)
: &(cel_u->tel);
*tar = _edit_or_mutate_cat(*tar, u3x_mas(axe_l), som);
}
}
cel_u->mug_w = 0;
}
}
static void
_mutate(u3_noun big, u3_noun axe, u3_noun som)
{
if ( c3y == u3a_is_cat(axe) ) {
_mutate_cat(big, (c3_l) axe, som);
}
else if ( c3n == u3du(big) ) {
u3m_bail(c3__exit);
}
else {
u3a_cell* cel_u = (void*) u3a_to_ptr(big);
u3_noun mor = u3qc_mas(axe);
u3_noun* tar = ( 2 == u3qc_cap(axe) )
? &(cel_u->hed)
: &(cel_u->tel);
*tar = _edit_or_mutate(*tar, mor, som);
cel_u->mug_w = 0;
u3z(mor);
}
}
static u3_noun
_edit_or_mutate_cat(u3_noun big, c3_l axe_l, u3_noun som)
{
if ( c3y == u3a_is_mutable(u3R, big) ) {
_mutate_cat(big, axe_l, som);
return big;
}
else {
return _edit_cat(big, axe_l, som);
}
}
static u3_noun
_edit_or_mutate(u3_noun big, u3_noun axe, u3_noun som)
{
if ( c3y == u3a_is_cat(axe) ) {
return _edit_or_mutate_cat(big, (c3_l) axe, som);
}
else if ( c3y == u3a_is_mutable(u3R, big) ) {
_mutate(big, axe, som);
return big;
}
else {
return _edit(big, axe, som);
}
}
/* u3i_edit():
**
** Mutate `big` at axis `axe` with new value `som`.
@ -730,15 +618,52 @@ _edit_or_mutate(u3_noun big, u3_noun axe, u3_noun som)
u3_noun
u3i_edit(u3_noun big, u3_noun axe, u3_noun som)
{
u3_noun pro;
u3_noun* out = &pro;
switch ( axe ) {
case 0:
return u3m_bail(c3__exit);
case 1:
u3z(big);
return som;
default:
return _edit_or_mutate(big, axe, som);
case 0: return u3m_bail(c3__exit);
case 1: break;
default: {
c3_w dep_w = u3r_met(0, u3x_atom(axe)) - 2;
const c3_w* axe_w = ( c3y == u3a_is_cat(axe) )
? &axe
: ((u3a_atom*)u3a_to_ptr(axe))->buf_w;
do {
u3a_cell* big_u = u3a_to_ptr(big);
u3_noun* old = (u3_noun*)&(big_u->hed);
const c3_y bit_y = 1 & (axe_w[dep_w >> 5] >> (dep_w & 31));
if ( c3n == u3a_is_cell(big) ) {
return u3m_bail(c3__exit);
}
else if ( c3y == u3a_is_mutable(u3R, big) ) {
*out = big;
out = &(old[bit_y]);
big = *out;
big_u->mug_w = 0;
}
else {
u3_noun luz = big;
u3_noun* new[2];
*out = u3i_defcons(&new[0], &new[1]);
out = new[bit_y];
big = u3k(old[bit_y]);
*(new[!bit_y]) = u3k(old[!bit_y]);
u3z(luz);
}
}
while ( dep_w-- );
}
}
u3z(big);
*out = som;
return pro;
}
/* u3i_molt():

View File

@ -14,7 +14,7 @@
#include "retrieve.h"
#include "serial.h"
#include "trace.h"
#include "urcrypt/urcrypt.h"
#include "urcrypt.h"
#include "vortex.h"
#include "xtract.h"
@ -1981,94 +1981,65 @@ u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor)
u3t_off(glu_o);
}
/* _cj_take_hank_cb(): u3h_take_with cb for taking hanks
/* _cj_reap_hank(): promote call site.
*/
static u3p(u3j_hank)
_cj_take_hank_cb(u3p(u3j_hank) nah_p)
static void
_cj_reap_hank(u3_cell kev)
{
u3j_hank* nah_u = u3to(u3j_hank, nah_p);
u3j_hank* han_u = u3a_walloc(c3_wiseof(u3j_hank));
u3a_cell* kev_u = u3a_to_ptr(kev);
u3j_hank* nah_u = u3to(u3j_hank, kev_u->tel);
u3j_hank* han_u;
u3_weak got;
u3_noun key;
if ( u3_none == nah_u->hax ) {
han_u->hax = u3_none;
// han_u->sit_u left uninitialized, will be ignored
return;
}
else {
// you have to keep what you take
//
key = u3a_take(kev_u->hed);
got = u3h_git(u3R->jed.han_p, key);
// promote
//
if ( u3_none == got ) {
han_u = u3a_walloc(c3_wiseof(u3j_hank));
han_u->hax = u3a_take(nah_u->hax);
u3j_site_take(&(han_u->sit_u), &(nah_u->sit_u));
}
return u3of(u3j_hank, han_u);
}
/* u3j_take(): copy junior jet state.
*/
u3a_jets
u3j_take(u3a_jets jed_u)
{
jed_u.war_p = u3h_take(jed_u.war_p);
jed_u.cod_p = u3h_take(jed_u.cod_p);
jed_u.han_p = u3h_take_with(jed_u.han_p, _cj_take_hank_cb);
jed_u.bas_p = u3h_take(jed_u.bas_p);
return jed_u;
}
/* _cj_merge_hank_cb(): u3h_uni_with cb for integrating taken hanks
** NB "transfers" or frees hanks in jed_u.han_p
*/
static void
_cj_merge_hank_cb(u3_noun kev, void* wit)
{
u3p(u3h_root) han_p = *(u3p(u3h_root)*)wit;
u3j_hank* nah_u;
u3_noun key;
u3p(u3j_hank) nah_p;
u3x_cell(kev, &key, &nah_p);
nah_u = u3to(u3j_hank, nah_p);
if ( u3_none == nah_u->hax ) {
u3a_wfree(nah_u);
}
// integrate
//
else {
u3j_hank* han_u;
u3_weak got = u3h_git(u3R->jed.han_p, key);
u3_weak old;
if ( u3_none == got ) {
han_u = nah_u;
han_u = u3to(u3j_hank, got);
old = han_u->hax;
han_u->hax = u3a_take(nah_u->hax);
u3j_site_take(&(nah_u->sit_u), &(nah_u->sit_u));
u3j_site_merge(&(han_u->sit_u), &(nah_u->sit_u));
if ( u3_none != old ) {
u3z(old);
}
else {
han_u = u3to(u3j_hank, got);
if ( u3_none != han_u->hax ) {
u3z(han_u->hax);
}
han_u->hax = nah_u->hax;
u3j_site_merge(&(han_u->sit_u), &(nah_u->sit_u));
u3a_wfree(nah_u);
}
u3h_put(han_p, key, u3of(u3j_hank, han_u));
}
u3h_put(u3R->jed.han_p, key, u3of(u3j_hank, han_u));
u3z(key);
}
/* u3j_reap(): promote jet state.
*/
void
u3j_reap(u3a_jets jed_u)
u3j_reap(u3a_jets* jed_u)
{
u3h_uni(u3R->jed.war_p, jed_u.war_p);
u3h_free(jed_u.war_p);
u3h_uni(u3R->jed.cod_p, jed_u.cod_p);
u3h_free(jed_u.cod_p);
u3h_walk_with(jed_u.han_p, _cj_merge_hank_cb, &u3R->jed.han_p);
u3h_free(jed_u.han_p);
u3h_uni(u3R->jed.bas_p, jed_u.bas_p);
u3h_free(jed_u.bas_p);
u3h_take_uni(u3R->jed.cod_p, jed_u->cod_p);
// call sites must be reaped before the warm dashboard;
// they may contain references to labels on this road
//
u3h_walk(jed_u->han_p, _cj_reap_hank);
u3h_take_uni(u3R->jed.war_p, jed_u->war_p);
u3h_take_uni(u3R->jed.bas_p, jed_u->bas_p);
}
/* _cj_ream(): ream list of battery [bash registry] pairs. RETAIN.

View File

@ -215,12 +215,7 @@
/* u3j_reap(): promote jet state.
*/
void
u3j_reap(u3a_jets jed_u);
/* u3j_take(): copy junior jet state.
*/
u3a_jets
u3j_take(u3a_jets jed_u);
u3j_reap(u3a_jets* jed_u);
/* u3j_rite_mine(): mine cor with clu, using u3j_rite for caching
*/

30
pkg/noun/jets/b/mate.c Normal file
View File

@ -0,0 +1,30 @@
/// @file
#include "jets/q.h"
#include "jets/w.h"
#include "noun.h"
u3_noun
u3qb_mate(u3_noun a,
u3_noun b)
{
if ( u3_nul == b ) {
return u3k(a);
} else if ( u3_nul == a ) {
return u3k(b);
} else if ( c3y == u3r_sing(u3t(a), u3t(b)) ) {
return u3k(a);
} else {
return u3m_error("mate");
}
}
u3_noun
u3wb_mate(u3_noun cor)
{
u3_noun a, b;
u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0);
return u3qb_mate(a, b);
}

View File

@ -5,32 +5,21 @@
#include "noun.h"
u3_noun
u3qc_cap(u3_atom a)
{
c3_w met_w = u3r_met(0, a);
u3_noun
u3qc_cap(u3_atom a)
{
c3_w met_w = u3r_met(0, a);
if ( met_w < 2 ) {
return u3m_bail(c3__exit);
}
else if ( (1 == u3r_bit((met_w - 2), a)) ) {
return 3;
} else {
return 2;
}
if ( 2 > met_w ) {
return u3m_bail(c3__exit);
}
u3_noun
u3wc_cap(u3_noun cor)
{
u3_noun a;
if ( (u3_none == (a = u3r_at(u3x_sam, cor))) ||
(c3n == u3ud(a)) )
{
return u3m_bail(c3__exit);
} else {
return u3qc_cap(a);
}
else {
return 2 + u3r_bit((met_w - 2), a);
}
}
u3_noun
u3wc_cap(u3_noun cor)
{
return u3qc_cap(u3x_atom(u3x_at(u3x_sam, cor)));
}

View File

@ -1,45 +1,48 @@
/// @file
#include "jets/q.h"
#include "jets/w.h"
#include "noun.h"
u3_noun
u3qc_mas(u3_atom a)
{
c3_w b_w;
u3_noun
u3qc_mas(u3_atom a)
{
c3_w b_w;
u3_atom c, d, e, f;
if ( c3y == u3a_is_cat(a) ) {
b_w = c3_bits_word(a);
b_w = u3r_met(0, a);
if ( b_w < 2 ) {
if ( 2 > b_w ) {
return u3m_bail(c3__exit);
}
else {
c = u3qc_bex((b_w - 1));
d = u3qc_bex((b_w - 2));
e = u3qa_sub(a, c);
f = u3qc_con(e, d);
u3z(c);
u3z(d);
u3z(e);
return f;
a &= ~((c3_w)1 << (b_w - 1));
a |= ((c3_w)1 << (b_w - 2));
return a;
}
}
u3_noun
u3wc_mas(u3_noun cor)
{
u3_noun a;
else {
b_w = u3r_met(0, a);
if ( (u3_none == (a = u3r_at(u3x_sam, cor))) ||
(c3n == u3ud(a)) )
{
return u3m_bail(c3__exit);
} else {
return u3qc_mas(a);
if ( 64 > b_w ) {
c3_d a_d = u3r_chub(0, a);
a_d &= ~((c3_d)1 << (b_w - 1));
a_d |= ((c3_d)1 << (b_w - 2));
return u3i_chub(a_d);
}
else {
u3i_slab sab_u;
u3i_slab_from(&sab_u, a, 0, b_w - 1);
b_w -= 2;
sab_u.buf_w[(b_w >> 5)] |= ((c3_w)1 << (b_w & 31));
return u3i_slab_mint(&sab_u);
}
}
}
u3_noun
u3wc_mas(u3_noun cor)
{
return u3qc_mas(u3x_atom(u3x_at(u3x_sam, cor)));
}

View File

@ -1,50 +1,66 @@
/// @file
#include "jets/q.h"
#include "jets/w.h"
#include "noun.h"
u3_noun
u3qc_peg(u3_atom a,
u3_atom b)
{
if ( 1 == b ) {
return u3k(a);
}
u3_atom c, d, e, f, g, h;
c = u3r_met(0, b);
d = u3qa_dec(c);
e = u3qc_lsh(0, d, 1);
f = u3qa_sub(b, e);
g = u3qc_lsh(0, d, a);
h = u3qa_add(f, g);
u3z(c);
u3z(d);
u3z(e);
u3z(f);
u3z(g);
return h;
u3_noun
u3qc_peg(u3_atom a, u3_atom b)
{
if ( (0 == a) || (0 == b) ) {
return u3m_bail(c3__exit);
}
u3_noun
u3wc_peg(u3_noun cor)
{
u3_noun a, b;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) ||
(0 == a) ||
(0 == b) ||
(c3n == u3ud(b)) ||
(c3n == u3ud(a) && b != 1) )
{
return u3m_bail(c3__exit);
} else {
return u3qc_peg(a, b);
}
else if ( 1 == b ) {
return u3k(a);
}
c3_d a_d, b_d;
c3_w c_w;
if ( (c3y == u3a_is_cat(a)) && (c3y == u3a_is_cat(b)) ) {
c_w = c3_bits_word(b) - 1;
a_d = a;
b_d = b;
}
else {
c3_w d_w = u3r_met(0, a);
c3_d e_d;
c_w = u3r_met(0, b) - 1;
e_d = (c3_d)c_w + d_w;
if ( 64 <= e_d ) {
u3i_slab sab_u;
u3i_slab_init(&sab_u, 0, e_d);
u3r_chop(0, 0, c_w, 0, sab_u.buf_w, b);
u3r_chop(0, 0, d_w, c_w, sab_u.buf_w, a);
return u3i_slab_moot(&sab_u);
}
a_d = u3r_chub(0, a);
b_d = u3r_chub(0, b);
}
b_d &= ((c3_d)1 << c_w) - 1;
a_d <<= c_w;
a_d ^= b_d;
return u3i_chub(a_d);
}
u3_noun
u3wc_peg(u3_noun cor)
{
u3_noun a, b;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) ||
(c3n == u3ud(b)) ||
(c3n == u3ud(a) && b != 1) )
{
return u3m_bail(c3__exit);
}
else {
return u3qc_peg(a, b);
}
}

View File

@ -5,63 +5,71 @@
#include "noun.h"
static u3_noun
_fitz_fiz(u3_noun yaz,
u3_noun wix)
{
c3_w yaz_w = u3r_met(3, yaz);
c3_w wix_w = u3r_met(3, wix);
c3_y yaz_y, wix_y;
static u3_noun
_fitz_fiz(u3_noun yaz,
u3_noun wix)
{
c3_w yaz_w = u3r_met(3, yaz);
c3_w wix_w = u3r_met(3, wix);
c3_y yaz_y, wix_y;
yaz_y = (0 == yaz_w) ? 0 : u3r_byte((yaz_w - 1), yaz);
if ( (yaz_y < 'A') || (yaz_y > 'Z') ) yaz_y = 0;
yaz_y = (0 == yaz_w) ? 0 : u3r_byte((yaz_w - 1), yaz);
if ( (yaz_y < 'A') || (yaz_y > 'Z') ) yaz_y = 0;
wix_y = (0 == wix_w) ? 0 : u3r_byte((wix_w - 1), wix);
if ( (wix_y < 'A') || (wix_y > 'Z') ) wix_y = 0;
wix_y = (0 == wix_w) ? 0 : u3r_byte((wix_w - 1), wix);
if ( (wix_y < 'A') || (wix_y > 'Z') ) wix_y = 0;
if ( yaz_y && wix_y ) {
if ( !wix_y || (wix_y > yaz_y) ) {
return c3n;
}
}
return c3y;
}
u3_noun
u3qf_fitz(u3_noun yaz,
u3_noun wix)
{
c3_w i_w, met_w = c3_min(u3r_met(3, yaz), u3r_met(3, wix));
if ( c3n == _fitz_fiz(yaz, wix) ) {
if ( yaz_y && wix_y ) {
if ( wix_y > yaz_y ) {
return c3n;
}
for ( i_w = 0; i_w < met_w; i_w++ ) {
c3_y yaz_y = u3r_byte(i_w, yaz);
c3_y wix_y = u3r_byte(i_w, wix);
if ( (yaz_y >= 'A') && (yaz_y <= 'Z') ) yaz_y = 0;
if ( (wix_y >= 'A') && (wix_y <= 'Z') ) wix_y = 0;
if ( yaz_y && wix_y && (yaz_y != wix_y) ) {
return c3n;
}
}
return c3y;
}
u3_noun
u3wf_fitz(u3_noun cor)
return c3y;
}
u3_noun
u3qf_fitz(u3_noun yaz,
u3_noun wix)
{
c3_w yet_w = u3r_met(3, yaz);
c3_w wet_w = u3r_met(3, wix);
c3_w i_w, met_w = c3_min(yet_w, wet_w);
if ( c3n == _fitz_fiz(yaz, wix) ) {
return c3n;
}
for ( i_w = 0; i_w < met_w; i_w++ ) {
c3_y yaz_y = u3r_byte(i_w, yaz);
c3_y wix_y = u3r_byte(i_w, wix);
if ( (i_w == (yet_w - 1)) && (yaz_y >= 'A') && (yaz_y <= 'Z')) {
return c3y;
}
if ( (i_w == (wet_w - 1)) && (wix_y >= 'A') && (wix_y <= 'Z')) {
return c3y;
}
if ( yaz_y != wix_y ) {
return c3n;
}
}
return c3y;
}
u3_noun
u3wf_fitz(u3_noun cor)
{
u3_noun yaz, wix;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &yaz, u3x_sam_3, &wix, 0)) ||
(c3n == u3ud(yaz)) ||
(c3n == u3ud(wix)) )
{
u3_noun yaz, wix;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &yaz, u3x_sam_3, &wix, 0)) ||
(c3n == u3ud(yaz)) ||
(c3n == u3ud(wix)) )
{
return u3m_bail(c3__fail);
} else {
return u3qf_fitz(yaz, wix);
}
return u3m_bail(c3__fail);
} else {
return u3qf_fitz(yaz, wix);
}
}

View File

@ -32,6 +32,7 @@
u3_noun u3qb_lien(u3_noun, u3_noun);
u3_noun u3qb_murn(u3_noun, u3_noun);
u3_noun u3qb_need(u3_noun);
u3_noun u3qb_mate(u3_noun, u3_noun);
u3_noun u3qb_reap(u3_atom, u3_noun);
u3_noun u3qb_reel(u3_noun, u3_noun);
u3_noun u3qb_roll(u3_noun, u3_noun);
@ -254,3 +255,4 @@
void u3qf_test(const c3_c*, u3_noun);
#endif /* ifndef U3_JETS_Q_H */

View File

@ -2273,6 +2273,8 @@ static u3j_core _139_two__in_d[] =
{}
};
static u3j_harm _139_two_mate_a[] = {{".2", u3wb_mate, c3y}, {}};
static u3j_core _139_two_d[] =
{ { "tri", 3, 0, _139_tri_d, no_hashes, _140_tri_ho },
@ -2283,6 +2285,7 @@ static u3j_core _139_two_d[] =
{ "lien", 7, _140_two_lien_a, 0, no_hashes },
{ "murn", 7, _140_two_murn_a, 0, no_hashes },
{ "need", 7, _140_two_need_a, 0, no_hashes },
{ "mate", 7, _139_two_mate_a, 0, no_hashes },
{ "reap", 7, _140_two_reap_a, 0, no_hashes },
{ "reel", 7, _140_two_reel_a, 0, no_hashes },
{ "roll", 7, _140_two_roll_a, 0, no_hashes },
@ -2445,3 +2448,4 @@ u3j_Dash = {
0,
0
};

View File

@ -32,6 +32,7 @@
u3_noun u3wb_lien(u3_noun);
u3_noun u3wb_murn(u3_noun);
u3_noun u3wb_need(u3_noun);
u3_noun u3wb_mate(u3_noun);
u3_noun u3wb_reap(u3_noun);
u3_noun u3wb_reel(u3_noun);
u3_noun u3wb_roll(u3_noun);
@ -332,3 +333,4 @@
u3_noun u3wfu_rest(u3_noun);
#endif /* ifndef U3_JETS_W_H */

View File

@ -860,6 +860,71 @@ _test_ob(void)
return ret_i;
}
static c3_i
_test_mas(void)
{
c3_i ret_i = 1;
u3_atom res;
if ( 0x4000 != (res = u3qc_mas(0x8000)) ) {
fprintf(stderr, "test mas fail: (mas 0x8000) != 0x4000: 0x'%x'\r\n", res);
ret_i = 0;
}
if ( 0x20000000 != (res = u3qc_mas(0x40000000)) ) {
fprintf(stderr, "test mas fail: (mas 0x4000.0000) != 0x2000.0000: 0x%x\r\n", res);
ret_i = 0;
}
{
u3_atom sam, pro;
sam = u3qc_bex(36);
pro = u3qc_bex(35);
res = u3qc_mas(sam);
if ( c3n == u3r_sing(pro, res) ) {
c3_c* out_c;
u3s_etch_ux_c(res, &out_c);
fprintf(stderr, "test mas fail: (mas (bex 36)) != (bex 35): %s\r\n", out_c);
c3_free(out_c);
ret_i = 0;
}
u3z(res); u3z(sam); u3z(pro);
sam = u3qc_bex(64);
pro = u3qc_bex(63);
res = u3qc_mas(sam);
if ( c3n == u3r_sing(pro, res) ) {
c3_c* out_c;
u3s_etch_ux_c(res, &out_c);
fprintf(stderr, "test mas fail: (mas (bex 64)) != (bex 63): %s\r\n", out_c);
c3_free(out_c);
ret_i = 0;
}
u3z(res); u3z(sam); u3z(pro);
sam = u3qc_bex(65);
pro = u3qc_bex(64);
res = u3qc_mas(sam);
if ( c3n == u3r_sing(pro, res) ) {
c3_c* out_c;
u3s_etch_ux_c(res, &out_c);
fprintf(stderr, "test mas fail: (mas (bex 65)) != (bex 64): %s\r\n", out_c);
c3_free(out_c);
ret_i = 0;
}
u3z(res); u3z(sam); u3z(pro);
}
return ret_i;
}
static c3_i
_test_jets(void)
{
@ -900,6 +965,11 @@ _test_jets(void)
ret_i = 0;
}
if ( !_test_mas() ) {
fprintf(stderr, "test jets: mas: failed\r\n");
ret_i = 0;
}
return ret_i;
}

View File

@ -22,7 +22,7 @@
#include "platform/rsignal.h"
#include "retrieve.h"
#include "trace.h"
#include "urcrypt/urcrypt.h"
#include "urcrypt.h"
#include "vortex.h"
#include "xtract.h"
@ -650,6 +650,10 @@ _find_home(void)
fprintf(stderr, "loom: strange size north (%u, %u)\r\n",
nor_w, u3P.nor_u.pgs_w);
}
// XX move me
//
u3a_ream();
}
/* As a further guard against any sneaky loom corruption */
@ -1003,24 +1007,21 @@ u3m_love(u3_noun pro)
//
u3m_fall();
// copy product and caches off our stack
// copy product off our stack
//
pro = u3a_take(pro);
jed_u = u3j_take(jed_u);
byc_p = u3n_take(byc_p);
per_p = u3h_take(per_p);
pro = u3a_take(pro);
// integrate junior caches
//
u3j_reap(&jed_u);
u3n_reap(byc_p);
u3z_reap(per_p);
// pop the stack
//
u3R->cap_p = u3R->ear_p;
u3R->ear_p = 0;
// integrate junior caches
//
u3j_reap(jed_u);
u3n_reap(byc_p);
u3z_reap(u3z_memo_keep, per_p);
return pro;
}

View File

@ -2879,12 +2879,11 @@ _cn_take_prog_dat(u3n_prog* dst_u, u3n_prog* src_u)
}
}
/* _cn_take_prog_cb(): u3h_take_with cb for taking junior u3n_prog's.
/* _cn_take_prog(): take junior u3n_prog.
*/
static u3p(u3n_prog)
_cn_take_prog_cb(u3p(u3n_prog) pog_p)
static u3n_prog*
_cn_take_prog(u3n_prog* pog_u)
{
u3n_prog* pog_u = u3to(u3n_prog, pog_p);
u3n_prog* gop_u;
if ( c3y == pog_u->byc_u.own_o ) {
@ -2900,17 +2899,8 @@ _cn_take_prog_cb(u3p(u3n_prog) pog_p)
}
_cn_take_prog_dat(gop_u, pog_u);
// _n_prog_take_dat(gop_u, pog_u, c3n);
return u3of(u3n_prog, gop_u);
}
/* u3n_take(): copy junior bytecode state.
*/
u3p(u3h_root)
u3n_take(u3p(u3h_root) har_p)
{
return u3h_take_with(har_p, _cn_take_prog_cb);
return gop_u;
}
/* _cn_merge_prog_dat(): copy references from src_u u3n_prog to dst_u.
@ -2945,29 +2935,36 @@ _cn_merge_prog_dat(u3n_prog* dst_u, u3n_prog* src_u)
}
}
/* _cn_merge_prog_cb(): u3h_walk_with cb for integrating taken u3n_prog's.
/* _cn_reap_prog_cb(): promote junior bytecode entry.
*/
static void
_cn_merge_prog_cb(u3_noun kev, void* wit)
_cn_reap_prog_cb(u3_cell kev)
{
u3p(u3h_root) har_p = *(u3p(u3h_root)*)wit;
u3n_prog* pog_u;
u3_weak got;
u3_noun key;
u3p(u3n_prog) pog_p;
u3x_cell(kev, &key, &pog_p);
u3a_cell* kev_u = u3a_to_ptr(kev);
u3_noun key = u3a_take(kev_u->hed);
u3n_prog* pog_u = u3to(u3n_prog, kev_u->tel);
u3_weak got = u3h_git(u3R->byc.har_p, key);
pog_u = u3to(u3n_prog, pog_p);
got = u3h_git(har_p, key);
if ( u3_none != got ) {
// promote
//
if ( u3_none == got ) {
pog_u = _cn_take_prog(pog_u);
}
// integrate
//
else {
u3n_prog* sep_u = u3to(u3n_prog, got);
_cn_take_prog_dat(pog_u, pog_u);
_cn_merge_prog_dat(sep_u, pog_u);
u3a_free(pog_u);
pog_u = sep_u;
}
u3h_put(har_p, key, u3of(u3n_prog, pog_u));
// we must always put, because we have taken.
// we must always keep what we have taken,
// or we can break relocation pointers.
//
u3h_put(u3R->byc.har_p, key, u3of(u3n_prog, pog_u));
u3z(key);
}
/* u3n_reap(): promote bytecode state.
@ -2975,9 +2972,7 @@ _cn_merge_prog_cb(u3_noun kev, void* wit)
void
u3n_reap(u3p(u3h_root) har_p)
{
u3h_walk_with(har_p, _cn_merge_prog_cb, &u3R->byc.har_p);
// NB *not* u3n_free, _cn_merge_prog_cb() transfers u3n_prog's
u3h_free(har_p);
u3h_walk(har_p, _cn_reap_prog_cb);
}
/* _n_ream(): ream program call sites

View File

@ -116,11 +116,6 @@
void
u3n_reap(u3p(u3h_root) har_p);
/* u3n_take(): copy junior bytecode state.
*/
u3p(u3h_root)
u3n_take(u3p(u3h_root) har_p);
/* u3n_mark(): mark bytecode cache.
*/
c3_w

View File

@ -11,7 +11,6 @@
# define u3R_v3 u3a_Road
# define u3a_v3_balign u3a_balign
# define u3a_v3_road u3a_road
# define u3a_v3_ream u3a_ream
# define u3a_v3_walign u3a_walign
# define u3a_v3_walloc u3a_walloc

View File

@ -100,9 +100,6 @@ u3m_v3_migrate()
u3R_v3 = &u3H_v3->rod_u;
u3H_v3->ver_w = U3V_VER3;
// recalculate free lists
u3a_v3_ream();
// initialize persistent cache
u3R_v3->cax.per_p = u3h_v3_new_cache(u3C.per_w);

View File

@ -5,6 +5,8 @@
#include "manage.h"
#include "retrieve.h"
u3_atom
u3x_atom(u3_noun a);
u3_noun
u3x_good(u3_weak som);

View File

@ -125,10 +125,7 @@ u3z_uniq(u3z_cid cid, u3_noun som)
/* u3z_reap(): promote memoization cache state.
*/
void
u3z_reap(u3z_cid cid, u3p(u3h_root) har_p)
u3z_reap(u3p(u3h_root) per_p)
{
u3_assert(u3z_memo_toss != cid);
u3h_uni(_har(u3R, cid), har_p);
u3h_free(har_p);
u3h_take_uni(u3R->cax.per_p, per_p);
}

View File

@ -50,10 +50,10 @@
u3_noun
u3z_uniq(u3z_cid cid, u3_noun som);
/* u3z_reap(): promote memoization cache state.
/* u3z_reap(): promote persistent memoization cache.
*/
void
u3z_reap(u3z_cid cid, u3p(u3h_root) har_p);
u3z_reap(u3p(u3h_root) per_p);
/* u3z_free(): free memoization cache.
*/

View File

@ -1,56 +0,0 @@
*.pc
config.h
config.status
libtool
# the following was adapted from
# https://github.com/github/gitignore/blob/991e760c1c6d50fdda246e0178b9c58b06770b90/Autotools.gitignore
# http://www.gnu.org/software/automake
Makefile.in
build-aux/ar-lib
/mdate-sh
/py-compile
/test-driver
/ylwrap
.deps/
.dirstamp
# http://www.gnu.org/software/autoconf
autom4te.cache
/autoscan.log
/autoscan-*.log
/aclocal.m4
build-aux/compile
/config.cache
build-aux/config.guess
/config.h.in
build-aux/config.log
build-aux/config.status
build-aux/config.sub
/configure
/configure.scan
build-aux/depcomp
build-aux/install-sh
build-aux/missing
/stamp-h1
# https://www.gnu.org/software/libtool/
build-aux/ltmain.sh
# http://www.gnu.org/software/m4/
build-aux/m4/libtool.m4
build-aux/m4/ltoptions.m4
build-aux/m4/ltsugar.m4
build-aux/m4/ltversion.m4
build-aux/m4/lt~obsolete.m4
# Generated Makefile
# (meta build system like autotools,
# can automatically generate from config.status script
# (which is called by configure script))
Makefile

View File

@ -1,36 +0,0 @@
#
# LIBRARIES
#
load("//bazel:common_settings.bzl", "vere_library")
vere_library(
name = "urcrypt",
srcs = glob(
[
"*.c",
"*.h",
],
exclude = ["urcrypt.h"],
),
hdrs = ["urcrypt.h"],
copts = [
"-Wall",
"-g",
"-O3",
],
include_prefix = "urcrypt",
includes = ["."],
linkstatic = True,
visibility = ["//pkg:__subpackages__"],
deps = [
"//pkg/urcrypt/ge-additions",
"@aes_siv",
"@argon2",
"@ed25519",
"@keccak_tiny",
"@openssl",
"@scrypt",
"@secp256k1",
],
)

View File

@ -1,33 +0,0 @@
What is urcrypt?
----------------
urcrypt is a library of cryptography routines used by urbit jets.
Why is urcrypt?
---------------
Urbit's C runtime (long the only urbit runtime) has accumulated a collection of
cryptography dependencies, some with custom additions or patches. These
libraries have different conventions and have been managed by u3 in an ad-hoc
manner. Reproducing that arrangement in other runtimes is tricky and
error-prone. The (sometimes inconsistent) logic must be reproduced and suitable
cryptography primitives must be found (or worse, written) for the new
environment.
To ease these burdens, urcrypt isolates the quirks behind a consistent calling
convention. Everything is a little-endian byte array, and each jetted operation
has a corresponding function in the library. Jets simply unpack their nouns,
call urcrypt, and pack the results.
What is a cryptography routine?
-------------------------------
This is more of a subjective question than it might appear. Any of the following
conditions are sufficient, but not necessary, for a function to be included in
urcrypt:
* The routine is sensitive to side-channel attacks (encryption, etc)
* Some property of the routine is cryptographically useful (SHA, RIPE, etc)
* The routine typically lives in a crypto library, for whatever reason.
A word on OpenSSL
-----------------
It is the library user's responsibility to initialize openssl, set custom memory
functions, etc.

View File

@ -1,181 +0,0 @@
#include "urcrypt.h"
#include "util.h"
#include <string.h>
#include <openssl/aes.h>
static int
urcrypt__cbc_pad(uint8_t **message_ptr,
size_t *length_ptr,
urcrypt_realloc_t realloc_ptr)
{
size_t length = *length_ptr,
remain = length % 16;
if ( 0 == remain ) {
// no padding needed
return 0;
}
else {
size_t padding = 16 - remain,
padded = length + padding;
if ( padded < length ) {
// size_t overflow
return -1;
}
else {
uint8_t *out = (*realloc_ptr)(*message_ptr, padded);
if ( NULL == out ) {
return -2;
}
else {
memset(out + length, 0, padding);
*message_ptr = out;
*length_ptr = padded;
return 0;
}
}
}
}
static int
urcrypt__cbc_help(uint8_t **message_ptr,
size_t *length_ptr,
const AES_KEY *key,
uint8_t ivec[16],
const int enc,
urcrypt_realloc_t realloc_ptr)
{
if ( 0 != urcrypt__cbc_pad(message_ptr, length_ptr, realloc_ptr) ) {
return -1;
}
else {
uint8_t *out = *message_ptr;
size_t length = *length_ptr;
urcrypt__reverse(16, ivec);
urcrypt__reverse(length, out);
AES_cbc_encrypt(out, out, length, key, ivec, enc);
urcrypt__reverse(length, out);
return 0;
}
}
int
urcrypt_aes_cbca_en(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[16],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr)
{
AES_KEY aes_key;
urcrypt__reverse(16, key);
if ( 0 != AES_set_encrypt_key(key, 128, &aes_key) ) {
return -1;
}
else {
return urcrypt__cbc_help(message_ptr, length_ptr,
&aes_key, ivec, AES_ENCRYPT, realloc_ptr);
}
}
int
urcrypt_aes_cbca_de(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[16],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr)
{
AES_KEY aes_key;
urcrypt__reverse(16, key);
if ( 0 != AES_set_decrypt_key(key, 128, &aes_key) ) {
return -1;
}
else {
return urcrypt__cbc_help(message_ptr, length_ptr,
&aes_key, ivec, AES_DECRYPT, realloc_ptr);
}
}
int
urcrypt_aes_cbcb_en(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[24],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr)
{
AES_KEY aes_key;
urcrypt__reverse(24, key);
if ( 0 != AES_set_encrypt_key(key, 192, &aes_key) ) {
return -1;
}
else {
return urcrypt__cbc_help(message_ptr, length_ptr,
&aes_key, ivec, AES_ENCRYPT, realloc_ptr);
}
}
int
urcrypt_aes_cbcb_de(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[24],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr)
{
AES_KEY aes_key;
urcrypt__reverse(24, key);
if ( 0 != AES_set_decrypt_key(key, 192, &aes_key) ) {
return -1;
}
else {
return urcrypt__cbc_help(message_ptr, length_ptr,
&aes_key, ivec, AES_DECRYPT, realloc_ptr);
}
}
int
urcrypt_aes_cbcc_en(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[32],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr)
{
AES_KEY aes_key;
urcrypt__reverse(32, key);
if ( 0 != AES_set_encrypt_key(key, 256, &aes_key) ) {
return -1;
}
else {
return urcrypt__cbc_help(message_ptr, length_ptr,
&aes_key, ivec, AES_ENCRYPT, realloc_ptr);
}
}
int
urcrypt_aes_cbcc_de(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[32],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr)
{
AES_KEY aes_key;
urcrypt__reverse(32, key);
if ( 0 != AES_set_decrypt_key(key, 256, &aes_key) ) {
return -1;
}
else {
return urcrypt__cbc_help(message_ptr, length_ptr,
&aes_key, ivec, AES_DECRYPT, realloc_ptr);
}
}

View File

@ -1,111 +0,0 @@
#include "urcrypt.h"
#include "util.h"
#include <openssl/aes.h>
int
urcrypt_aes_ecba_en(uint8_t key[16], uint8_t block[16], uint8_t out[16])
{
AES_KEY aes_key;
urcrypt__reverse(16, key);
urcrypt__reverse(16, block);
if ( 0 != AES_set_encrypt_key(key, 128, &aes_key) ) {
return -1;
}
else {
AES_ecb_encrypt(block, out, &aes_key, AES_ENCRYPT);
urcrypt__reverse(16, out);
return 0;
}
}
int
urcrypt_aes_ecba_de(uint8_t key[16], uint8_t block[16], uint8_t out[16])
{
AES_KEY aes_key;
urcrypt__reverse(16, key);
urcrypt__reverse(16, block);
if ( 0 != AES_set_decrypt_key(key, 128, &aes_key) ) {
return -1;
}
else {
AES_ecb_encrypt(block, out, &aes_key, AES_DECRYPT);
urcrypt__reverse(16, out);
return 0;
}
}
int
urcrypt_aes_ecbb_en(uint8_t key[24], uint8_t block[16], uint8_t out[16])
{
AES_KEY aes_key;
urcrypt__reverse(24, key);
urcrypt__reverse(16, block);
if ( 0 != AES_set_encrypt_key(key, 192, &aes_key) ) {
return -1;
}
else {
AES_ecb_encrypt(block, out, &aes_key, AES_ENCRYPT);
urcrypt__reverse(16, out);
return 0;
}
}
int
urcrypt_aes_ecbb_de(uint8_t key[24], uint8_t block[16], uint8_t out[16])
{
AES_KEY aes_key;
urcrypt__reverse(24, key);
urcrypt__reverse(16, block);
if ( 0 != AES_set_decrypt_key(key, 192, &aes_key) ) {
return -1;
}
else {
AES_ecb_encrypt(block, out, &aes_key, AES_DECRYPT);
urcrypt__reverse(16, out);
return 0;
}
}
int
urcrypt_aes_ecbc_en(uint8_t key[32], uint8_t block[16], uint8_t out[16])
{
AES_KEY aes_key;
urcrypt__reverse(32, key);
urcrypt__reverse(16, block);
if ( 0 != AES_set_encrypt_key(key, 256, &aes_key) ) {
return -1;
}
else {
AES_ecb_encrypt(block, out, &aes_key, AES_ENCRYPT);
urcrypt__reverse(16, out);
return 0;
}
}
int
urcrypt_aes_ecbc_de(uint8_t key[32], uint8_t block[16], uint8_t out[16])
{
AES_KEY aes_key;
urcrypt__reverse(32, key);
urcrypt__reverse(16, block);
if ( 0 != AES_set_decrypt_key(key, 256, &aes_key) ) {
return -1;
}
else {
AES_ecb_encrypt(block, out, &aes_key, AES_DECRYPT);
urcrypt__reverse(16, out);
return 0;
}
}

View File

@ -1,181 +0,0 @@
#include "urcrypt.h"
#include "util.h"
#include "aes_siv.h"
static AES_SIV_CTX*
urcrypt__aes_siv_init(uint8_t *key,
size_t key_length,
urcrypt_aes_siv_data *data,
size_t data_length)
{
AES_SIV_CTX *ctx = AES_SIV_CTX_new();
if ( NULL == ctx ) {
return NULL;
}
else {
urcrypt__reverse(key_length, key);
if ( 0 == AES_SIV_Init(ctx, key, key_length) ) {
AES_SIV_CTX_free(ctx);
return NULL;
}
else {
size_t i, len;
uint8_t *dat;
for ( i = 0; i < data_length; ++i ) {
len = data[i].length;
dat = data[i].bytes;
urcrypt__reverse(len, dat);
if ( 0 == AES_SIV_AssociateData(ctx, dat, len) ) {
AES_SIV_CTX_free(ctx);
return NULL;
}
}
return ctx;
}
}
}
static int
urcrypt__aes_siv_en(uint8_t *key,
size_t key_length,
uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t iv[16],
uint8_t *out)
{
AES_SIV_CTX *ctx = urcrypt__aes_siv_init(key, key_length, data, data_length);
if ( NULL == ctx ) {
return -1;
}
else {
int ret;
urcrypt__reverse(message_length, message);
ret = AES_SIV_EncryptFinal(ctx, iv, out, message, message_length);
AES_SIV_CTX_free(ctx);
if ( 0 == ret ) {
return -2;
}
else {
urcrypt__reverse(16, iv);
urcrypt__reverse(message_length, out);
return 0;
}
}
}
static int
urcrypt__aes_siv_de(uint8_t *key,
size_t key_length,
uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t iv[16],
uint8_t *out)
{
AES_SIV_CTX *ctx = urcrypt__aes_siv_init(key, key_length, data, data_length);
if ( NULL == ctx ) {
return -1;
}
else {
int ret;
urcrypt__reverse(message_length, message);
urcrypt__reverse(16, iv);
ret = AES_SIV_DecryptFinal(ctx, out, iv, message, message_length);
AES_SIV_CTX_free(ctx);
if ( 0 == ret ) {
return -2;
}
else {
urcrypt__reverse(message_length, out);
return 0;
}
}
}
int
urcrypt_aes_siva_en(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[32],
uint8_t iv[16],
uint8_t *out)
{
return urcrypt__aes_siv_en(key, 32,
message, message_length, data, data_length, iv, out);
}
int
urcrypt_aes_siva_de(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[32],
uint8_t iv[16],
uint8_t *out)
{
return urcrypt__aes_siv_de(key, 32,
message, message_length, data, data_length, iv, out);
}
int
urcrypt_aes_sivb_en(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[48],
uint8_t iv[16],
uint8_t *out)
{
return urcrypt__aes_siv_en(key, 48,
message, message_length, data, data_length, iv, out);
}
int
urcrypt_aes_sivb_de(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[48],
uint8_t iv[16],
uint8_t *out)
{
return urcrypt__aes_siv_de(key, 48,
message, message_length, data, data_length, iv, out);
}
int
urcrypt_aes_sivc_en(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[64],
uint8_t iv[16],
uint8_t *out)
{
return urcrypt__aes_siv_en(key, 64,
message, message_length, data, data_length, iv, out);
}
int
urcrypt_aes_sivc_de(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[64],
uint8_t iv[16],
uint8_t *out)
{
return urcrypt__aes_siv_de(key, 64,
message, message_length, data, data_length, iv, out);
}

View File

@ -1,120 +0,0 @@
#include "urcrypt.h"
#include "util.h"
#include <argon2.h>
#include <blake2.h>
// library convention is to have sizes in size_t, but argon2 wants them
// in uint32_t, so here's a helper macro for ensuring equivalence.
#define SZ_32(s) ( sizeof(size_t) <= sizeof(uint32_t) || s <= 0xFFFFFFFF )
const char*
urcrypt_argon2(uint8_t type,
uint32_t version,
uint32_t threads,
uint32_t memory_cost,
uint32_t time_cost,
size_t secret_length,
uint8_t *secret,
size_t associated_length,
uint8_t *associated,
size_t password_length,
uint8_t *password,
size_t salt_length,
uint8_t *salt,
size_t out_length,
uint8_t *out,
urcrypt_argon2_alloc_t alloc_ptr,
urcrypt_argon2_free_t free_ptr)
{
if ( !( SZ_32(secret_length) &&
SZ_32(associated_length) &&
SZ_32(password_length) &&
SZ_32(salt_length) &&
SZ_32(out_length) ) ) {
return "length > 32 bits";
}
else {
int (*f)(argon2_context*);
int result;
switch ( type ) {
default:
return "unknown type";
case urcrypt_argon2_d:
f = &argon2d_ctx;
break;
case urcrypt_argon2_i:
f = &argon2i_ctx;
break;
case urcrypt_argon2_id:
f = &argon2id_ctx;
break;
case urcrypt_argon2_u:
f = &argon2u_ctx;
break;
}
urcrypt__reverse(secret_length, secret);
urcrypt__reverse(associated_length, associated);
urcrypt__reverse(password_length, password);
urcrypt__reverse(salt_length, salt);
argon2_context context = {
out, // output array, at least [digest length] in size
out_length, // digest length
password, // password array
password_length, // password length
salt, // salt array
salt_length, // salt length
secret, // optional secret data
secret_length,
associated, // optional associated data
associated_length,
time_cost, // performance cost configuration
memory_cost,
threads,
threads,
version, // algorithm version
alloc_ptr, // custom memory allocation function
free_ptr, // custom memory deallocation function
ARGON2_DEFAULT_FLAGS // by default only internal memory is cleared
};
result = (*f)(&context);
if ( ARGON2_OK != result ) {
return argon2_error_message(result);
}
else {
urcrypt__reverse(out_length, out);
return NULL;
}
}
}
int
urcrypt_blake2(size_t message_length,
uint8_t *message,
size_t key_length,
uint8_t key[64],
size_t out_length,
uint8_t *out)
{
if ( key_length > 64 ) {
return -1;
}
else {
urcrypt__reverse(message_length, message);
urcrypt__reverse(key_length, key);
if ( 0 != blake2b(out, out_length,
message, message_length,
key, key_length)) {
return -1;
}
else {
urcrypt__reverse(out_length, out);
return 0;
}
}
}

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1,53 +0,0 @@
#include "urcrypt.h"
#include <string.h>
#include <ed25519.h>
void
urcrypt_ed_puck(const uint8_t seed[32],
uint8_t out[32])
{
uint8_t secret[64];
ed25519_create_keypair(out, secret, seed);
}
void
urcrypt_ed_shar(const uint8_t public[32],
const uint8_t seed[32],
uint8_t out[32])
{
uint8_t self[32], exp[64];
memset(self, 0, 32);
memset(exp, 0, 64);
memset(out, 0, 32);
ed25519_create_keypair(self, exp, seed);
ed25519_key_exchange(out, public, exp);
}
void
urcrypt_ed_sign(const uint8_t *message,
size_t length,
const uint8_t seed[32],
uint8_t out[64])
{
uint8_t public[64], secret[64];
memset(public, 0, 64);
memset(secret, 0, 64);
memset(out, 0, 64);
ed25519_create_keypair(public, secret, seed);
ed25519_sign(out, message, length, public, secret);
}
bool
urcrypt_ed_veri(const uint8_t *message,
size_t length,
const uint8_t public[32],
const uint8_t signature[64])
{
return ( ed25519_verify(signature, message, length, public) == 1 )
? true
: false;
}

View File

@ -1,11 +0,0 @@
load("//bazel:common_settings.bzl", "vere_library")
vere_library(
name = "ge-additions",
srcs = ["ge-additions.c"],
hdrs = ["ge-additions.h"],
includes = ["."],
linkstatic = True,
visibility = ["//pkg/urcrypt:__pkg__"],
deps = ["@ed25519"],
)

View File

@ -1,27 +0,0 @@
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,20 +0,0 @@
# Group Element Additions
Urbit uses the ge.h code from the ed25519 library, which was ported from the
ref10 SUPERCOP public domain implementation. That implementation doesn't
contain several functions needed for ring signatures.
This file does. The providence of this code starts with Adam Langley taking
the SUPERCOP C implementation and producing an ed25519 implementation for it
in golang (https://godoc.org/golang.org/x/crypto/ed25519). (If you look at
the go code, you'll see the comments are the same as the comments in the C
implementation.)
From there, the DEDIS group from ETH Zurich took that implementation and
added the additional methods to make a generalized ECC point library. While
their project as a whole is MPL, they deliberately left their ed25519
implementation under the Go BSD-3 license:
(https://github.com/dedis/kyber/blob/master/group/edwards25519/LICENSE)
This file is a fairly straight translation from Go to C of DEDIS' additions,
so this falls under the same license.

View File

@ -1,169 +0,0 @@
// Group Element Additions
//
// Urbit uses the ge.h code from the ed25519 library, which was ported from the
// ref10 SUPERCOP public domain implementation. That implementation doesn't
// contain several functions needed for ring signatures.
//
// This file does. The providence of this code starts with Adam Langley taking
// the SUPERCOP C implementation and producing an ed25519 implementation for it
// in golang (https://godoc.org/golang.org/x/crypto/ed25519). (If you look at
// the go code, you'll see the comments are the same as the comments in the C
// implementation.)
//
// From there, the DEDIS group from ETH Zurich took that implementation and
// added the additional methods to make a generalized ECC point library. While
// their project as a whole is MPL, they deliberately left their ed25519
// implementation under the Go BSD-3 license:
// (https://github.com/dedis/kyber/blob/master/group/edwards25519/LICENSE)
//
// This file is a fairly straight translation from Go to C of DEDIS' additions,
// so this falls under the same license.
//
// ------
//
// Copyright (c) 2009 The Go Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ge-additions.h"
#include <fe.h>
static unsigned char equal(signed char b, signed char c) {
unsigned char ub = b;
unsigned char uc = c;
unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */
uint64_t y = x; /* 0: yes; 1..255: no */
y -= 1; /* large: yes; 0..254: no */
y >>= 63; /* 1: yes; 0: no */
return (unsigned char) y;
}
static unsigned char negative(signed char b) {
uint64_t x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */
x >>= 63; /* 1: yes; 0: no */
return (unsigned char) x;
}
void ge_cached_0(ge_cached* c) {
fe_1(c->YplusX);
fe_1(c->YminusX);
fe_1(c->Z);
fe_0(c->T2d);
}
void ge_cached_cmov(ge_cached* r, const ge_cached* u, int32_t b)
{
fe_cmov(r->YplusX, u->YplusX, b);
fe_cmov(r->YminusX, u->YminusX, b);
fe_cmov(r->Z, u->Z, b);
fe_cmov(r->T2d, u->T2d, b);
}
void ge_cached_neg(ge_cached* r, const ge_cached* t)
{
fe_copy(r->YplusX, t->YminusX);
fe_copy(r->YminusX, t->YplusX);
fe_copy(r->Z, t->Z);
fe_neg(r->T2d, t->T2d);
}
void select_cached(ge_cached* c, const ge_cached Ai[8], int32_t b)
{
int32_t is_negative = negative(b);
int32_t b_abs = b - (((-is_negative) & b) << 1);
ge_cached_0(c);
for (int32_t i = 0; i < 8; ++i) {
ge_cached_cmov(c, &Ai[i], equal(b_abs, i+1));
}
ge_cached minusC;
ge_cached_neg(&minusC, c);
ge_cached_cmov(c, &minusC, is_negative);
}
//
void ge_scalarmult(ge_p3* h, const unsigned char* a, const ge_p3* A)
{
signed char e[64];
int i;
ge_p1p1 t;
ge_p3 u;
for (i = 0; i < 32; ++i) {
e[2 * i + 0] = (a[i] >> 0) & 15;
e[2 * i + 1] = (a[i] >> 4) & 15;
}
/* each e[i] is between 0 and 15 */
/* e[63] is between 0 and 7 */
signed char carry = 0;
for (i = 0; i < 63; ++i) {
e[i] += carry;
carry = e[i] + 8;
carry >>= 4;
e[i] -= carry << 4;
}
e[63] += carry;
/* each e[i] is between -8 and 8 */
// compute cached array of multiples of A from 1A through 8A
ge_cached Ai[8];
ge_p3_to_cached(&Ai[0], A);
for (i = 0; i < 7; ++i) {
ge_add(&t, A, &Ai[i]);
ge_p1p1_to_p3(&u, &t);
ge_p3_to_cached(&Ai[i+1], &u);
}
// special case for exponent nybble i == 63
ge_p3_0(&u);
ge_cached c;
select_cached(&c, Ai, e[63]);
ge_add(&t, &u, &c);
ge_p2 r;
for (i = 62; i >= 0; i--) {
// t <<= 4
ge_p1p1_to_p2(&r, &t);
ge_p2_dbl(&t, &r);
ge_p1p1_to_p2(&r, &t);
ge_p2_dbl(&t, &r);
ge_p1p1_to_p2(&r, &t);
ge_p2_dbl(&t, &r);
ge_p1p1_to_p2(&r, &t);
ge_p2_dbl(&t, &r);
// Add next nyble
ge_p1p1_to_p3(&u, &t);
select_cached(&c, Ai, e[i]);
ge_add(&t, &u, &c);
}
ge_p1p1_to_p3(h, &t);
}

View File

@ -1,8 +0,0 @@
#ifndef GE_ADDITIONS_H
#define GE_ADDITIONS_H
#include <ge.h>
void ge_scalarmult(ge_p3* h, const unsigned char* a, const ge_p3* A);
#endif

View File

@ -1,126 +0,0 @@
#include "urcrypt.h"
#include <ge-additions.h>
int
urcrypt_ed_point_add(const uint8_t a[32],
const uint8_t b[32],
uint8_t out[32])
{
ge_p3 A, B;
ge_cached b_cached;
ge_p1p1 sum;
ge_p3 result;
if ( ge_frombytes_negate_vartime(&A, a) != 0 ) {
return -1;
}
if ( ge_frombytes_negate_vartime(&B, b) != 0 ) {
return -1;
}
// Undo the negation from above. See add_scalar.c in the ed25519 distro.
fe_neg(A.X, A.X);
fe_neg(A.T, A.T);
fe_neg(B.X, B.X);
fe_neg(B.T, B.T);
ge_p3_to_cached(&b_cached, &B);
ge_add(&sum, &A, &b_cached);
ge_p1p1_to_p3(&result, &sum);
ge_p3_tobytes(out, &result);
return 0;
}
int
urcrypt_ed_scalarmult(const uint8_t a[32],
const uint8_t b[32],
uint8_t out[32])
{
ge_p3 B, result;
if ( ge_frombytes_negate_vartime(&B, b) != 0 ) {
return -1;
}
// Undo the negation from above. See add_scalar.c in the ed25519 distro.
fe_neg(B.X, B.X);
fe_neg(B.T, B.T);
ge_scalarmult(&result, a, &B);
ge_p3_tobytes(out, &result);
return 0;
}
void
urcrypt_ed_scalarmult_base(const uint8_t a[32],
uint8_t out[32])
{
ge_p3 R;
ge_scalarmult_base(&R, a);
ge_p3_tobytes(out, &R);
}
int
urcrypt_ed_add_scalarmult_scalarmult_base(const uint8_t a[32],
const uint8_t a_point[32],
const uint8_t b[32],
uint8_t out[32])
{
ge_p2 r;
ge_p3 A;
if (ge_frombytes_negate_vartime(&A, a_point) != 0) {
return -1;
}
// Undo the negation from above. See add_scalar.c in the ed25519 distro.
fe_neg(A.X, A.X);
fe_neg(A.T, A.T);
ge_double_scalarmult_vartime(&r, a, &A, b);
ge_tobytes(out, &r);
return 0;
}
int
urcrypt_ed_add_double_scalarmult(const uint8_t a[32],
const uint8_t a_point[32],
const uint8_t b[32],
const uint8_t b_point[32],
uint8_t out[32])
{
ge_p3 A, B, a_result, b_result, final_result;
ge_cached b_result_cached;
ge_p1p1 sum;
if ( ge_frombytes_negate_vartime(&A, a_point) != 0 ) {
return -1;
}
if ( ge_frombytes_negate_vartime(&B, b_point) != 0 ) {
return -1;
}
// Undo the negation from above. See add_scalar.c in the ed25519 distro.
fe_neg(A.X, A.X);
fe_neg(A.T, A.T);
fe_neg(B.X, B.X);
fe_neg(B.T, B.T);
// Perform the multiplications of a*A and b*B
ge_scalarmult(&a_result, a, &A);
ge_scalarmult(&b_result, b, &B);
// Sum those two points
ge_p3_to_cached(&b_result_cached, &b_result);
ge_add(&sum, &a_result, &b_result_cached);
ge_p1p1_to_p3(&final_result, &sum);
ge_p3_tobytes(out, &final_result);
return 0;
}

View File

@ -1,21 +0,0 @@
#include "urcrypt.h"
#include "util.h"
#include <keccak-tiny.h>
#define defkec(bits,byts) \
int urcrypt_keccak_##bits(const uint8_t *message, size_t length, \
uint8_t out[byts]) \
{ \
if ( 0 == keccak_##bits(out, byts, message, length) ) { \
urcrypt__reverse(byts, out); \
return 0; \
} \
else { \
return -1; \
}\
}
defkec(224, 28)
defkec(256, 32)
defkec(384, 48)
defkec(512, 64)

View File

@ -1,20 +0,0 @@
#include "urcrypt.h"
#include "util.h"
#include <openssl/ripemd.h>
int
urcrypt_ripemd160(uint8_t *message, size_t length, uint8_t out[20])
{
unsigned long n = length;
if ( length != n ) {
return -1;
}
else {
urcrypt__reverse(length, message);
RIPEMD160(message, n, out);
urcrypt__reverse(20, out);
return 0;
}
}

View File

@ -1,31 +0,0 @@
#include "urcrypt.h"
#include <libscrypt.h>
#include <sha256.h>
void
urcrypt_scrypt_pbkdf_sha256(const uint8_t *passwd,
size_t passwdlen,
const uint8_t *salt,
size_t saltlen,
uint64_t count,
size_t outlen, // must be at most 32*(2^32-1)
uint8_t *out)
{
libscrypt_PBKDF2_SHA256(
passwd, passwdlen, salt, saltlen, count, out, outlen);
}
int
urcrypt_scrypt(const uint8_t *passwd,
size_t passwdlen,
const uint8_t *salt,
size_t saltlen,
uint64_t n,
uint32_t r,
uint32_t p,
size_t outlen,
uint8_t *out)
{
return libscrypt_scrypt(
passwd, passwdlen, salt, saltlen, n, r, p, out, outlen);
}

View File

@ -1,245 +0,0 @@
#include "urcrypt.h"
#include "util.h"
#include <string.h>
#include <secp256k1.h>
#include <secp256k1_extrakeys.h>
#include <secp256k1_recovery.h>
#include <secp256k1_preallocated.h>
#include <secp256k1_schnorrsig.h>
#define SECP_FLAGS SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN
struct urcrypt_secp_context_struct {
secp256k1_context* secp;
uint8_t prealloc[];
};
size_t
urcrypt_secp_prealloc_size()
{
return sizeof(urcrypt_secp_context) +
secp256k1_context_preallocated_size(SECP_FLAGS);
}
int
urcrypt_secp_init(urcrypt_secp_context *context,
uint8_t entropy[32])
{
secp256k1_context* secp =
secp256k1_context_preallocated_create(context->prealloc, SECP_FLAGS);
if ( 1 == secp256k1_context_randomize(secp, entropy) ) {
context->secp = secp;
return 0;
}
else {
secp256k1_context_preallocated_destroy(secp);
return -1;
}
}
void
urcrypt_secp_destroy(urcrypt_secp_context *context)
{
secp256k1_context_preallocated_destroy(context->secp);
}
int
urcrypt_secp_make(uint8_t hash[32], uint8_t key[32], uint8_t out[32])
{
urcrypt__reverse(32, hash);
urcrypt__reverse(32, key);
if ( 1 != secp256k1_nonce_function_rfc6979(
out, // OUT: return arg for nonce
hash, // IN: message / hash */
key, // IN: key32
NULL, // IN: algorithm (NULL == ECDSA)
NULL, // IN: arbitrary data pointer (unused)
0) ) { // IN: attempt number (0 == normal)
return -1;
}
else {
urcrypt__reverse(32, out);
return 0;
}
}
int
urcrypt_secp_sign(urcrypt_secp_context* context,
uint8_t hash[32],
uint8_t key[32],
uint8_t* out_v,
uint8_t out_r[32],
uint8_t out_s[32])
{
secp256k1_ecdsa_recoverable_signature signature;
urcrypt__reverse(32, hash);
urcrypt__reverse(32, key);
/* sign
N.B. if we want the 'v' field we can't use default secp256k1_ecdsa_sign(),
but must use secp256k1_ecdsa_sign_recoverable() */
if ( 1 != secp256k1_ecdsa_sign_recoverable(
context->secp, /* IN: context object */
&signature, /* OUT: signature */
hash, /* IN: 32 byte hash to be signed */
key, /* IN: 32 byte secret key */
NULL, /* IN: nonce-function ptr ; NULL = default */
NULL) ) { /* IN: data for nonce function; not used */
return -1;
}
else {
uint8_t sigbytes[64];
int recid;
if ( 1 != secp256k1_ecdsa_recoverable_signature_serialize_compact(
context->secp, /* IN: context object */
sigbytes, /* OUT: 64 byte sig (r,s) */
&recid, /* OUT: v */
&signature) ) { /* IN: 65 byte sig */
return -2;
}
else {
/* read sigbytes into r and s
convert endianness while we're at it */
uint8_t i, j;
for ( j = 31, i = 0; i < 32; ++i, --j) {
out_r[j] = sigbytes[i];
}
for ( j = 31; i < 64; ++i, --j ) {
out_s[j] = sigbytes[i];
}
*out_v = (uint8_t) recid;
return 0;
}
}
}
int
urcrypt_secp_reco(urcrypt_secp_context* context,
uint8_t hash[32],
uint8_t key_v,
const uint8_t key_r[32],
const uint8_t key_s[32],
uint8_t out_x[32],
uint8_t out_y[32])
{
if ( (NULL == hash) ||
(NULL == key_r) ||
(NULL == key_s) ) {
return -1;
}
else if ( key_v > 3 ) {
return -2;
}
else {
secp256k1_ecdsa_recoverable_signature signature;
uint8_t private[64];
uint8_t i, j;
// make big private key out of two smaller parts, reversing endianness
for ( j = 31, i = 0; i < 32; ++i, --j) {
private[i] = key_r[j];
}
for ( j = 31; i < 64; ++i, --j ) {
private[i] = key_s[j];
}
memset(&signature, 0, sizeof(secp256k1_ecdsa_recoverable_signature));
if ( 1 != secp256k1_ecdsa_recoverable_signature_parse_compact(
context->secp, /* IN: context */
&signature, /* OUT: sig */
private, /* IN: r/s */
key_v) ) { /* IN: v */
return -3;
}
else {
secp256k1_pubkey public;
memset(&public, 0, sizeof(secp256k1_pubkey));
urcrypt__reverse(32, hash);
if ( 1 != secp256k1_ecdsa_recover(
context->secp, /* IN: context */
&public, /* OUT: pub key */
&signature, /* IN: signature */
hash) ) { /* IN: message hash */
return -4;
}
else {
/* convert pub into serialized form that we can get x, y out of */
uint8_t serialized[65];
size_t outputlen = 65;
memset(serialized, 0, outputlen);
if ( 1 != secp256k1_ec_pubkey_serialize(
context->secp, /* IN: context */
serialized, /* OUT: output */
&outputlen, /* IN/OUT: outputlen */
&public, /* IN: pubkey*/
SECP256K1_EC_UNCOMPRESSED) ) { /* IN: flags */
return -5;
}
else {
/* in file
subprojects/secp256k1/src/eckey_impl.h
func
secp256k1_eckey_pubkey_parse()
we can see
byte 0: signal bits (???)
bytes 1-32: x
bytes 33-64: y
convert endianness while we're at it */
for (j = 32, i = 0; i < 32; ++i, --j) {
out_x[i] = serialized[j];
}
for (j = 64, i = 0; i < 32; ++i, --j) {
out_y[i] = serialized[j];
}
return 0;
}
}
}
}
}
int
urcrypt_secp_schnorr_sign(urcrypt_secp_context* context,
uint8_t key[32],
uint8_t msg[32],
uint8_t aux[32],
uint8_t out_sig[64])
{
secp256k1_keypair keypair;
urcrypt__reverse(32, key);
urcrypt__reverse(32, msg);
urcrypt__reverse(32, aux);
if ( 1 != secp256k1_keypair_create(context->secp, &keypair, key) ) {
return -1;
}
if ( 1 != secp256k1_schnorrsig_sign32(context->secp, out_sig, msg, &keypair, aux) ) {
return -1;
}
urcrypt__reverse(64, out_sig);
return 0;
}
bool
urcrypt_secp_schnorr_veri(urcrypt_secp_context* context,
uint8_t sig[64],
uint8_t msg[32],
uint8_t pub[32])
{
secp256k1_xonly_pubkey pubkey;
urcrypt__reverse(64, sig);
urcrypt__reverse(32, msg);
urcrypt__reverse(32, pub);
if ( 1 != secp256k1_xonly_pubkey_parse(context->secp, &pubkey, pub) ) {
return false;
}
if ( 1 != secp256k1_schnorrsig_verify(context->secp, sig, msg, 32, &pubkey) ) {
return false;
}
return true;
}

View File

@ -1,49 +0,0 @@
#include "urcrypt.h"
#include "util.h"
#include <openssl/sha.h>
void
urcrypt_sha1(uint8_t *message, size_t length, uint8_t out[20])
{
urcrypt__reverse(length, message);
SHA1(message, length, out);
urcrypt__reverse(20, out);
}
void
urcrypt_shay(const uint8_t *message, size_t length, uint8_t out[32])
{
SHA256(message, length, out);
}
void
urcrypt_shal(const uint8_t *message, size_t length, uint8_t out[64])
{
SHA512(message, length, out);
}
void
urcrypt_shas(uint8_t *salt, size_t salt_length,
const uint8_t *message, size_t message_length,
uint8_t out[32])
{
size_t i;
uint8_t mid[32];
// docs don't say what happens if msg overlaps with out
urcrypt_shay(message, message_length, mid);
if ( salt_length > 32 ) {
for ( i = 0; i < 32; i++ ) {
salt[i] ^= mid[i];
}
urcrypt_shay(salt, salt_length, out);
}
else {
for ( i = 0; i < salt_length; i++ ) {
mid[i] ^= salt[i];
}
urcrypt_shay(mid, 32, out);
}
}

View File

@ -1,246 +0,0 @@
#ifndef URCRYPT_H
#define URCRYPT_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
// const arguments are not written to, non-const arguments may be
// all arrays are in little-endian byte order.
// array sizes[64] are purely documentary
// 0 on success, result in out
int urcrypt_ed_point_add(const uint8_t a[32],
const uint8_t b[32],
uint8_t out[32]);
int urcrypt_ed_scalarmult(const uint8_t a[32],
const uint8_t b[32],
uint8_t out[32]);
// void functions have no failure mode
void urcrypt_ed_scalarmult_base(const uint8_t a[32],
uint8_t out[32]);
int urcrypt_ed_add_scalarmult_scalarmult_base(const uint8_t a[32],
const uint8_t a_point[32],
const uint8_t b[32],
uint8_t out[32]);
int urcrypt_ed_add_double_scalarmult(const uint8_t a[32],
const uint8_t a_point[32],
const uint8_t b[32],
const uint8_t b_point[32],
uint8_t out[32]);
void urcrypt_ed_puck(const uint8_t seed[32],
uint8_t out[32]);
void urcrypt_ed_shar(const uint8_t public[32],
const uint8_t seed[32],
uint8_t out[32]);
void urcrypt_ed_sign(const uint8_t *message,
size_t length,
const uint8_t seed[32],
uint8_t out[64]);
// return value means the signature was (not) verified
bool urcrypt_ed_veri(const uint8_t *message,
size_t length,
const uint8_t public[32],
const uint8_t signature[64]);
int urcrypt_aes_ecba_en(uint8_t key[16], uint8_t block[16], uint8_t out[16]);
int urcrypt_aes_ecba_de(uint8_t key[16], uint8_t block[16], uint8_t out[16]);
int urcrypt_aes_ecbb_en(uint8_t key[24], uint8_t block[16], uint8_t out[16]);
int urcrypt_aes_ecbb_de(uint8_t key[24], uint8_t block[16], uint8_t out[16]);
int urcrypt_aes_ecbc_en(uint8_t key[32], uint8_t block[16], uint8_t out[16]);
int urcrypt_aes_ecbc_de(uint8_t key[32], uint8_t block[16], uint8_t out[16]);
typedef void* (*urcrypt_realloc_t)(void*, size_t);
// message and length are read/write so
// realloc_ptr can be used as realloc to pad message
int urcrypt_aes_cbca_en(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[16],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr);
int urcrypt_aes_cbca_de(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[16],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr);
int urcrypt_aes_cbcb_en(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[24],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr);
int urcrypt_aes_cbcb_de(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[24],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr);
int urcrypt_aes_cbcc_en(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[32],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr);
int urcrypt_aes_cbcc_de(uint8_t **message_ptr,
size_t *length_ptr,
uint8_t key[32],
uint8_t ivec[16],
urcrypt_realloc_t realloc_ptr);
typedef struct {
size_t length;
uint8_t *bytes;
} urcrypt_aes_siv_data;
int urcrypt_aes_siva_en(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[32],
uint8_t iv[16],
uint8_t *out);
int urcrypt_aes_siva_de(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[32],
uint8_t iv[16],
uint8_t *out);
int urcrypt_aes_sivb_en(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[48],
uint8_t iv[16],
uint8_t *out);
int urcrypt_aes_sivb_de(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[48],
uint8_t iv[16],
uint8_t *out);
int urcrypt_aes_sivc_en(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[64],
uint8_t iv[16],
uint8_t *out);
int urcrypt_aes_sivc_de(uint8_t *message,
size_t message_length,
urcrypt_aes_siv_data *data,
size_t data_length,
uint8_t key[64],
uint8_t iv[16],
uint8_t *out);
int urcrypt_ripemd160(uint8_t *message, size_t length, uint8_t out[20]);
void urcrypt_sha1(uint8_t *message, size_t length, uint8_t out[20]);
void urcrypt_shay(const uint8_t *message, size_t length, uint8_t out[32]);
void urcrypt_shal(const uint8_t *message, size_t length, uint8_t out[64]);
void urcrypt_shas(uint8_t *salt, size_t salt_length,
const uint8_t *message, size_t message_length,
uint8_t out[32]);
typedef int (*urcrypt_argon2_alloc_t)(uint8_t**, size_t);
typedef void (*urcrypt_argon2_free_t)(uint8_t*, size_t);
#define urcrypt_argon2_d 0
#define urcrypt_argon2_i 1
#define urcrypt_argon2_id 2
#define urcrypt_argon2_u 10
/* returns a constant error message string or NULL for success */
const char* urcrypt_argon2(uint8_t type, // one of the urcrpyt_argon2_*
uint32_t version,
uint32_t threads,
uint32_t memory_cost,
uint32_t time_cost,
size_t secret_length,
uint8_t *secret,
size_t associated_length,
uint8_t *associated,
size_t password_length,
uint8_t *password,
size_t salt_length,
uint8_t *salt,
size_t out_length,
uint8_t *out,
urcrypt_argon2_alloc_t alloc_ptr,
urcrypt_argon2_free_t free_ptr);
int urcrypt_blake2(size_t message_length,
uint8_t *message,
size_t key_length,
uint8_t key[64],
size_t out_length,
uint8_t *out);
/* there is some long-term context associated with the secp library
* (precomputed tables, etc), so secp functions require a context object
*/
typedef struct urcrypt_secp_context_struct urcrypt_secp_context;
// size of opaque secp handle, malloc and pass to init
size_t urcrypt_secp_prealloc_size(void);
// call this once at per context with high quality entropy
int urcrypt_secp_init(urcrypt_secp_context *context,
uint8_t entropy[32]);
// call before freeing opaque secp handle
void urcrypt_secp_destroy(urcrypt_secp_context *context);
int urcrypt_secp_make(uint8_t hash[32], uint8_t key[32], uint8_t out[32]);
int urcrypt_secp_sign(urcrypt_secp_context* context,
uint8_t hash[32],
uint8_t key[32],
uint8_t* out_v,
uint8_t out_r[32],
uint8_t out_s[32]);
int urcrypt_secp_reco(urcrypt_secp_context* context,
uint8_t hash[32],
uint8_t key_v, // 0, 1, 2, 3
const uint8_t key_r[32],
const uint8_t key_s[32],
uint8_t out_x[32],
uint8_t out_y[32]);
int urcrypt_secp_schnorr_sign(urcrypt_secp_context* context,
uint8_t key[32],
uint8_t msg[32],
uint8_t aux[32],
uint8_t out_sig[64]);
// return value means signature was (not) verified
bool urcrypt_secp_schnorr_veri(urcrypt_secp_context* context,
uint8_t sig[64],
uint8_t msg[32],
uint8_t pub[32]);
void urcrypt_scrypt_pbkdf_sha256(const uint8_t *passwd,
size_t passwdlen,
const uint8_t *salt,
size_t saltlen,
uint64_t count,
size_t outlen, // must be at most 32*(2^32-1)
uint8_t *out);
int urcrypt_scrypt(const uint8_t *passwd,
size_t passwdlen,
const uint8_t *salt,
size_t saltlen,
uint64_t n,
uint32_t r,
uint32_t p,
size_t outlen,
uint8_t *out);
int urcrypt_keccak_224(const uint8_t *message,
size_t length,
uint8_t out[28]);
int urcrypt_keccak_256(const uint8_t *message,
size_t length,
uint8_t out[32]);
int urcrypt_keccak_384(const uint8_t *message,
size_t length,
uint8_t out[48]);
int urcrypt_keccak_512(const uint8_t *message,
size_t length,
uint8_t out[64]);
#endif

View File

@ -1,14 +0,0 @@
#include "urcrypt.h"
void
urcrypt__reverse(size_t size, uint8_t *ptr) {
if ( size > 0 ) {
size_t i, j;
uint8_t tmp;
for ( i = 0, j = size - 1; i < j; i++, j-- ) {
tmp = ptr[i];
ptr[i] = ptr[j];
ptr[j] = tmp;
}
}
}

View File

@ -1,6 +0,0 @@
#ifndef URCRYPT_UTIL_H
#define URCRYPT_UTIL_H
void urcrypt__reverse(size_t size, uint8_t *ptr);
#endif

View File

@ -1,6 +1,7 @@
/// @file
#include "noun.h"
#include "jets/q.h"
#include "ur.h"
#include "vere.h"
@ -387,6 +388,63 @@ _cue_soft_bench(void)
u3z(vat);
}
static void
_edit_bench_impl(c3_w max_w)
{
u3_assert( max_w && (c3y == u3a_is_cat(max_w)) );
c3_w* axe_w = c3_calloc(((max_w + 31) >> 5) << 2);
c3_w bit_w;
u3_noun lit = u3qb_reap(max_w, 1);
u3_noun axe;
axe_w[0] = bit_w = 2;
do {
axe = u3i_words((bit_w + 31) >> 5, axe_w);
lit = u3i_edit(lit, axe, 2);
u3z(axe);
axe_w[bit_w >> 5] |= (c3_w)1 << (bit_w & 31);
bit_w++;
}
while ( bit_w <= max_w );
u3z(lit);
c3_free(axe_w);
}
static void
_edit_bench(void)
{
struct timeval b4, f2, d0;
c3_w mil_w;
fprintf(stderr, "\r\nopcode 10 microbenchmark:\r\n");
{
gettimeofday(&b4, 0);
_edit_bench_impl(1000);
gettimeofday(&f2, 0);
timersub(&f2, &b4, &d0);
mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000);
fprintf(stderr, " opcode 10 1k list: %u ms\r\n", mil_w);
}
{
gettimeofday(&b4, 0);
_edit_bench_impl(10000);
gettimeofday(&f2, 0);
timersub(&f2, &b4, &d0);
mil_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000);
fprintf(stderr, " opcode 10 10k list: %u ms\r\n", mil_w);
}
}
/* main(): run all benchmarks
*/
int
@ -397,6 +455,7 @@ main(int argc, char* argv[])
_jam_bench();
_cue_bench();
_cue_soft_bench();
_edit_bench();
// GC
//

View File

@ -70,6 +70,7 @@ typedef enum u3_stun_state {
u3_lane sef_u; // our lane, if we know it
c3_o wok_o; // STUN worked, set on first success
} sun_u; //
c3_o nal_o; // lane cache backcompat flag
struct { // config:
c3_o net_o; // can send
c3_o see_o; // can scry
@ -945,13 +946,22 @@ _ames_lane_into_cache(u3p(u3h_root) lax_p, u3_noun who, u3_noun las) {
u3z(who);
}
/* _ames_lane_from_cache(): retrieve lane for who from cache, if any & fresh
/* _ames_lane_from_cache(): retrieve lane for who from cache, if any
*/
static u3_weak
_ames_lane_from_cache(u3p(u3h_root) lax_p, u3_noun who) {
_ames_lane_from_cache(u3p(u3h_root) lax_p, u3_noun who, c3_o nal_o) {
u3_weak lac = u3h_git(lax_p, who);
if ( u3_none != lac ) {
if ( u3_none == lac ) {
u3z(who);
return lac;
}
if ( nal_o == c3y ) {
lac = u3k(u3h(lac));
}
else {
struct timeval tim_tv;
gettimeofday(&tim_tv, 0);
u3_noun now = u3_time_in_tv(&tim_tv);
@ -1161,7 +1171,7 @@ _ames_czar(u3_pact* pac_u)
}
}
/* _fine_put_cache(): get packet list or status from cache. RETAIN
/* _fine_get_cache(): get packet list or status from cache. RETAIN
*/
static u3_weak
_fine_get_cache(u3_ames* sam_u, u3_noun pax, c3_w fra_w)
@ -2097,7 +2107,7 @@ _ames_try_send(u3_pact* pac_u, c3_o for_o)
//
else {
u3_noun key = u3i_chubs(2, pac_u->pre_u.rec_d);
lac = _ames_lane_from_cache(sam_u->lax_p, key);
lac = _ames_lane_from_cache(sam_u->lax_p, key, sam_u->nal_o);
}
// if we know there's no lane, drop the packet
@ -2279,7 +2289,7 @@ _fine_hunk_scry_cb(void* vod_p, u3_noun nun)
u3z(nun);
}
/* _fine_hear_request(): hear wail (fine equeust packet packet).
/* _fine_hear_request(): hear wail (fine request packet packet).
*/
static void
_fine_hear_request(u3_pact* req_u, c3_w cur_w)
@ -2923,6 +2933,14 @@ _ames_kick_newt(u3_ames* sam_u, u3_noun tag, u3_noun dat)
case c3__saxo: {
_ames_ef_saxo(sam_u, u3k(dat));
ret_o = c3y;
}
case c3__nail: {
u3_noun who = u3k(u3h(dat));
u3_noun las = u3k(u3t(dat));
_ames_lane_into_cache(sam_u->lax_p, who, las);
sam_u->nal_o = c3y;
ret_o = c3y;
} break;
}
@ -3105,6 +3123,7 @@ u3_ames_io_init(u3_pier* pir_u)
{
u3_ames* sam_u = c3_calloc(sizeof(*sam_u));
sam_u->pir_u = pir_u;
sam_u->nal_o = c3n;
sam_u->fig_u.net_o = c3y;
sam_u->fig_u.see_o = c3y;
sam_u->fig_u.fit_o = c3n;