diff --git a/pkg/urbit/include/noun/retrieve.h b/pkg/urbit/include/noun/retrieve.h index 295ad622af..8eb6ed880f 100644 --- a/pkg/urbit/include/noun/retrieve.h +++ b/pkg/urbit/include/noun/retrieve.h @@ -346,21 +346,22 @@ c3_y* c_y, u3_atom d); - /* u3r_unpack(): + /* u3r_bytes_fit(): ** ** Copy (len_w) bytes of (a) into (buf_y) if it fits, returning overage */ c3_w - u3r_unpack(c3_w len_w, - c3_y *buf_y, - u3_atom a); + u3r_bytes_fit(c3_w len_w, + c3_y* buf_y, + u3_atom a); - /* u3r_unpack_alloc(): + /* u3r_bytes_all(): ** ** Allocate a new byte array with all the bytes of (a) */ c3_y* - u3r_unpack_alloc(c3_w* len_w, u3_atom a); + u3r_bytes_all(c3_w* len_w, + u3_atom a); /* u3r_chop(): ** diff --git a/pkg/urbit/jets/e/aes_cbc.c b/pkg/urbit/jets/e/aes_cbc.c index 19e1291322..06d9df3811 100644 --- a/pkg/urbit/jets/e/aes_cbc.c +++ b/pkg/urbit/jets/e/aes_cbc.c @@ -25,7 +25,7 @@ typedef c3_y* (*urcrypt_cbc)(const c3_y*, u3r_bytes(0, 16, iv_y, iv); - msg_y = u3r_unpack_alloc(&met_w, msg); + msg_y = u3r_bytes_all(&met_w, msg); out_y = (*low_f)(msg_y, met_w, key_y, iv_y, &len); u3a_free(msg_y); diff --git a/pkg/urbit/jets/e/ed_add_double_scalarmult.c b/pkg/urbit/jets/e/ed_add_double_scalarmult.c index e49a0bf168..af73d59644 100644 --- a/pkg/urbit/jets/e/ed_add_double_scalarmult.c +++ b/pkg/urbit/jets/e/ed_add_double_scalarmult.c @@ -14,10 +14,10 @@ { c3_y a_y[32], b_y[32], c_y[32], d_y[32], out_y[32]; - if ( (0 != u3r_unpack(32, a_y, a)) || - (0 != u3r_unpack(32, b_y, b)) || - (0 != u3r_unpack(32, c_y, c)) || - (0 != u3r_unpack(32, d_y, d)) || + if ( (0 != u3r_bytes_fit(32, a_y, a)) || + (0 != u3r_bytes_fit(32, b_y, b)) || + (0 != u3r_bytes_fit(32, c_y, c)) || + (0 != u3r_bytes_fit(32, d_y, d)) || (0 != urcrypt_ed_add_double_scalarmult(a_y, b_y, c_y, d_y, out_y)) ) { return u3_none; } diff --git a/pkg/urbit/jets/e/ed_add_scalarmult_scalarmult_base.c b/pkg/urbit/jets/e/ed_add_scalarmult_scalarmult_base.c index 0a0e2d2d48..2db437aec4 100644 --- a/pkg/urbit/jets/e/ed_add_scalarmult_scalarmult_base.c +++ b/pkg/urbit/jets/e/ed_add_scalarmult_scalarmult_base.c @@ -13,9 +13,9 @@ { c3_y a_y[32], b_y[32], c_y[32], out_y[32]; - if ( (0 != u3r_unpack(32, a_y, a)) || - (0 != u3r_unpack(32, b_y, b)) || - (0 != u3r_unpack(32, c_y, c)) || + if ( (0 != u3r_bytes_fit(32, a_y, a)) || + (0 != u3r_bytes_fit(32, b_y, b)) || + (0 != u3r_bytes_fit(32, c_y, c)) || (0 != urcrypt_ed_add_scalarmult_scalarmult_base(a_y, b_y, c_y, out_y)) ) { return u3_none; } diff --git a/pkg/urbit/jets/e/ed_point_add.c b/pkg/urbit/jets/e/ed_point_add.c index a93f798b30..2a5da29384 100644 --- a/pkg/urbit/jets/e/ed_point_add.c +++ b/pkg/urbit/jets/e/ed_point_add.c @@ -13,8 +13,8 @@ { c3_y a_y[32], b_y[32], out_y[32]; - if ( (0 != u3r_unpack(32, a_y, a)) || - (0 != u3r_unpack(32, b_y, b)) || + if ( (0 != u3r_bytes_fit(32, a_y, a)) || + (0 != u3r_bytes_fit(32, b_y, b)) || (0 != urcrypt_ed_point_add(a_y, b_y, out_y)) ) { return u3_none; } diff --git a/pkg/urbit/jets/e/ed_puck.c b/pkg/urbit/jets/e/ed_puck.c index 8257b937ec..436650e1ab 100644 --- a/pkg/urbit/jets/e/ed_puck.c +++ b/pkg/urbit/jets/e/ed_puck.c @@ -11,7 +11,7 @@ { c3_y sed_y[32]; - if ( 0 != u3r_unpack(32, sed_y, sed) ) { + if ( 0 != u3r_bytes_fit(32, sed_y, sed) ) { // hoon explicitly crashes on mis-size return u3m_bail(c3__exit); } diff --git a/pkg/urbit/jets/e/ed_scalarmult.c b/pkg/urbit/jets/e/ed_scalarmult.c index 224fba3f6d..97c88c4f67 100644 --- a/pkg/urbit/jets/e/ed_scalarmult.c +++ b/pkg/urbit/jets/e/ed_scalarmult.c @@ -12,8 +12,8 @@ { c3_y a_y[32], b_y[32], out_y[32]; - if ( (0 != u3r_unpack(32, a_y, a)) || - (0 != u3r_unpack(32, b_y, b)) || + if ( (0 != u3r_bytes_fit(32, a_y, a)) || + (0 != u3r_bytes_fit(32, b_y, b)) || (0 != urcrypt_ed_scalarmult(a_y, b_y, out_y)) ) { // hoon does not check size of inputs return u3_none; diff --git a/pkg/urbit/jets/e/ed_scalarmult_base.c b/pkg/urbit/jets/e/ed_scalarmult_base.c index c1b641bd95..9756e65a5a 100644 --- a/pkg/urbit/jets/e/ed_scalarmult_base.c +++ b/pkg/urbit/jets/e/ed_scalarmult_base.c @@ -11,7 +11,7 @@ { c3_y a_y[32]; - if ( 0 != u3r_unpack(32, a_y, a) ) { + if ( 0 != u3r_bytes_fit(32, a_y, a) ) { return u3_none; } else { diff --git a/pkg/urbit/jets/e/ed_shar.c b/pkg/urbit/jets/e/ed_shar.c index 5ed28df377..7db4e61752 100644 --- a/pkg/urbit/jets/e/ed_shar.c +++ b/pkg/urbit/jets/e/ed_shar.c @@ -9,11 +9,11 @@ { c3_y pub_y[32], sek_y[32]; - if ( 0 != u3r_unpack(32, pub_y, pub) ) { + if ( 0 != u3r_bytes_fit(32, pub_y, pub) ) { // pub is not size checked in the hoon return u3_none; } - else if ( 0 != u3r_unpack(32, sek_y, sek) ) { + else if ( 0 != u3r_bytes_fit(32, sek_y, sek) ) { // sek explicitly bails through suck return u3m_bail(c3__exit); } diff --git a/pkg/urbit/jets/e/ed_sign.c b/pkg/urbit/jets/e/ed_sign.c index e6a153ba1c..09fd317d06 100644 --- a/pkg/urbit/jets/e/ed_sign.c +++ b/pkg/urbit/jets/e/ed_sign.c @@ -12,14 +12,14 @@ { c3_y sed_y[32]; - if ( 0 != u3r_unpack(32, sed_y, b) ) { + if ( 0 != u3r_bytes_fit(32, sed_y, b) ) { // hoon calls suck, which calls puck, which crashes return u3m_bail(c3__exit); } else { c3_y sig_y[64]; c3_w met_w; - c3_y* mes_y = u3r_unpack_alloc(&met_w, a); + c3_y* mes_y = u3r_bytes_all(&met_w, a); urcrypt_ed_sign(mes_y, met_w, sed_y, sig_y); u3a_free(mes_y); diff --git a/pkg/urbit/jets/e/ed_veri.c b/pkg/urbit/jets/e/ed_veri.c index f4bf30ac34..c4a4b6f2df 100644 --- a/pkg/urbit/jets/e/ed_veri.c +++ b/pkg/urbit/jets/e/ed_veri.c @@ -13,14 +13,14 @@ { c3_y sig_y[64], pub_y[32]; - if ( (0 != u3r_unpack(64, sig_y, s)) || - (0 != u3r_unpack(32, pub_y, pk)) ) { + if ( (0 != u3r_bytes_fit(64, sig_y, s)) || + (0 != u3r_bytes_fit(32, pub_y, pk)) ) { // hoon checks sizes, but weirdly and without crashes return u3_none; } else { c3_w met_w; - c3_y* mes_y = u3r_unpack_alloc(&met_w, m); + c3_y* mes_y = u3r_bytes_all(&met_w, m); c3_t val_t = urcrypt_ed_veri(mes_y, met_w, pub_y, sig_y); u3a_free(mes_y); diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index b8f875b862..8354d42436 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -1076,12 +1076,12 @@ u3r_bytes(c3_w a_w, } } -/* u3r_unpack(): +/* u3r_bytes_fit(): ** ** Copy (len_w) bytes of (a) into (buf_y) if it fits, returning overage */ c3_w -u3r_unpack(c3_w len_w, c3_y *buf_y, u3_atom a) +u3r_bytes_fit(c3_w len_w, c3_y *buf_y, u3_atom a) { c3_w met_w = u3r_met(3, a); if ( met_w <= len_w ) { @@ -1093,12 +1093,12 @@ u3r_unpack(c3_w len_w, c3_y *buf_y, u3_atom a) } } -/* u3r_unpack_alloc(): +/* u3r_bytes_all(): ** ** Allocate a new byte array with all the bytes of (a) */ c3_y* -u3r_unpack_alloc(c3_w* len_w, u3_atom a) +u3r_bytes_all(c3_w* len_w, u3_atom a) { c3_w met_w = u3r_met(3, a); c3_y* a_y = u3a_malloc(met_w);