Skip to content

Commit

Permalink
uint32_pack_big remove, switch to cryptoint
Browse files Browse the repository at this point in the history
  • Loading branch information
janmojzis committed Nov 30, 2024
1 parent 124b0b4 commit edd5078
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 48 deletions.
32 changes: 14 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ OBJLIB=blocking.o buf.o byte.o channel.o channel_drop.o channel_fork.o \
sshcrypto_cipher_chachapoly.o sshcrypto_kex.o sshcrypto_kex_curve25519.o \
sshcrypto_kex_sntrup761x25519.o sshcrypto_key.o sshcrypto_key_ed25519.o str.o \
stringparser.o subprocess_auth.o subprocess_sign.o trymlock.o \
uint16_optblocker.o uint32_optblocker.o uint32_pack_big.o uint64_optblocker.o \
uint8_optblocker.o writeall.o
uint16_optblocker.o uint32_optblocker.o uint64_optblocker.o uint8_optblocker.o \
writeall.o

OBJALL=blocking.o buf.o byte.o channel.o channel_drop.o channel_fork.o \
channel_forkpty.o channel_subsystem.o cleanup.o coe.o connectioninfo.o \
Expand All @@ -62,7 +62,7 @@ OBJALL=blocking.o buf.o byte.o channel.o channel_drop.o channel_fork.o \
_tinysshd-printkex.o _tinysshd-speed.o _tinysshd-test-hello1.o \
_tinysshd-test-hello2.o _tinysshd-test-kex1.o _tinysshd-test-kex2.o \
_tinysshd-unauthenticated.o trymlock.o uint16_optblocker.o uint32_optblocker.o \
uint32_pack_big.o uint64_optblocker.o uint8_optblocker.o writeall.o
uint64_optblocker.o uint8_optblocker.o writeall.o

AUTOHEADERS=haslib25519.h haslibntruprime.h haslibrandombytes.h haslibutilh.h \
haslimits.h haslogintty.h hasmlock.h hasopenpty.h hasutilh.h hasutmpaddrv6.h \
Expand All @@ -81,8 +81,8 @@ blocking.o: blocking.c blocking.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c blocking.c

buf.o: buf.c byte.h str.h purge.h cleanup.h randombytes.h \
haslibrandombytes.h uint32_pack_big.h crypto_uint32.h bug.h global.h e.h \
log.h buf.h crypto_uint8.h
haslibrandombytes.h crypto_uint32.h bug.h global.h e.h log.h buf.h \
crypto_uint8.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c buf.c

byte.o: byte.c byte.h
Expand Down Expand Up @@ -373,9 +373,9 @@ packet_channel_request.o: packet_channel_request.c buf.h crypto_uint8.h \

packet_channel_send.o: packet_channel_send.c bug.h global.h e.h log.h \
buf.h crypto_uint8.h crypto_uint32.h channel.h iptostr.h porttostr.h \
limit.h haslimits.h ssh.h uint32_pack_big.h packet.h sshcrypto.h \
crypto.h crypto_int16.h crypto_int32.h crypto_int64.h crypto_int8.h \
crypto_uint16.h crypto_uint64.h crypto_verify_16.h crypto_verify_32.h \
limit.h haslimits.h ssh.h packet.h sshcrypto.h crypto.h crypto_int16.h \
crypto_int32.h crypto_int64.h crypto_int8.h crypto_uint16.h \
crypto_uint64.h crypto_verify_16.h crypto_verify_32.h \
haslibrandombytes.h randombytes.h crypto_hash_sha256.h \
crypto_hash_sha512.h haslib25519.h crypto_kem_sntrup761.h \
haslibntruprime.h crypto_kem_sntrup761x25519.h \
Expand Down Expand Up @@ -439,13 +439,12 @@ packetparser.o: packetparser.c e.h crypto_uint32.h bug.h global.h log.h \
byte.h packetparser.h crypto_uint8.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c packetparser.c

packet_put.o: packet_put.c uint32_pack_big.h crypto_uint32.h buf.h \
crypto_uint8.h bug.h global.h e.h log.h sshcrypto.h crypto.h \
crypto_int16.h crypto_int32.h crypto_int64.h crypto_int8.h \
crypto_uint16.h crypto_uint64.h crypto_verify_16.h crypto_verify_32.h \
haslibrandombytes.h randombytes.h crypto_hash_sha256.h \
crypto_hash_sha512.h haslib25519.h crypto_kem_sntrup761.h \
haslibntruprime.h crypto_kem_sntrup761x25519.h \
packet_put.o: packet_put.c crypto_uint32.h buf.h crypto_uint8.h bug.h \
global.h e.h log.h sshcrypto.h crypto.h crypto_int16.h crypto_int32.h \
crypto_int64.h crypto_int8.h crypto_uint16.h crypto_uint64.h \
crypto_verify_16.h crypto_verify_32.h haslibrandombytes.h randombytes.h \
crypto_hash_sha256.h crypto_hash_sha512.h haslib25519.h \
crypto_kem_sntrup761.h haslibntruprime.h crypto_kem_sntrup761x25519.h \
crypto_onetimeauth_poly1305.h crypto_scalarmult_curve25519.h \
crypto_dh_x25519.h crypto_sign_ed25519.h crypto_sort_uint32.h \
crypto_stream_chacha20.h ssh.h packet.h limit.h haslimits.h channel.h \
Expand Down Expand Up @@ -748,9 +747,6 @@ uint16_optblocker.o: uint16_optblocker.c crypto_uint16.h
uint32_optblocker.o: uint32_optblocker.c crypto_uint32.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c uint32_optblocker.c

uint32_pack_big.o: uint32_pack_big.c uint32_pack_big.h crypto_uint32.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c uint32_pack_big.c

uint64_optblocker.o: uint64_optblocker.c crypto_uint64.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c uint64_optblocker.c

Expand Down
4 changes: 2 additions & 2 deletions buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ immediately exits with 111 status code.
#include "str.h"
#include "purge.h"
#include "randombytes.h"
#include "uint32_pack_big.h"
#include "crypto_uint32.h"
#include "bug.h"
#include "buf.h"

Expand Down Expand Up @@ -127,7 +127,7 @@ int buf_putnum32_(const char *fn, unsigned long long line,

unsigned char s[4];

uint32_pack_big(s, x);
crypto_uint32_store_bigendian(s, x);
return buf_put_(fn, line, b, s, sizeof s);
}

Expand Down
12 changes: 6 additions & 6 deletions packet_channel_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Public domain.
#include "channel.h"
#include "ssh.h"
#include "bug.h"
#include "uint32_pack_big.h"
#include "crypto_uint32.h"
#include "packet.h"

void packet_channel_send_data(struct buf *b) {
Expand All @@ -31,8 +31,8 @@ void packet_channel_send_data(struct buf *b) {
if (r == 0) return;
b->len = r + 9;
b->buf[0] = SSH_MSG_CHANNEL_DATA; /* byte SSH_MSG_CHANNEL_DATA */
uint32_pack_big(b->buf + 1, channel_getid()); /* uint32 recipient channel */
uint32_pack_big(b->buf + 5, r); /* string data */
crypto_uint32_store_bigendian(b->buf + 1, channel_getid()); /* uint32 recipient channel */
crypto_uint32_store_bigendian(b->buf + 5, r); /* string data */
packet_put(b);
buf_purge(b);
return;
Expand All @@ -57,9 +57,9 @@ void packet_channel_send_extendeddata(struct buf *b) {
if (r == 0) return;
b->len = r + 13;
b->buf[0] = SSH_MSG_CHANNEL_EXTENDED_DATA; /* byte SSH_MSG_CHANNEL_EXTENDED_DATA */
uint32_pack_big(b->buf + 1, channel_getid()); /* uint32 recipient channel */
uint32_pack_big(b->buf + 5, 1); /* uint32 data_type_code (1 = stderr) */
uint32_pack_big(b->buf + 9, r); /* string data */
crypto_uint32_store_bigendian(b->buf + 1, channel_getid()); /* uint32 recipient channel */
crypto_uint32_store_bigendian(b->buf + 5, 1); /* uint32 data_type_code (1 = stderr) */
crypto_uint32_store_bigendian(b->buf + 9, r); /* string data */
packet_put(b);
buf_purge(b);
return;
Expand Down
4 changes: 2 additions & 2 deletions packet_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Jan Mojzis
Public domain.
*/

#include "uint32_pack_big.h"
#include "crypto_uint32.h"
#include "buf.h"
#include "bug.h"
#include "sshcrypto.h"
Expand All @@ -30,7 +30,7 @@ static void packet_put_plain_(struct buf *b) {
sendbuf->buf[pos + 4] = paddinglen;

/* add packet length */
uint32_pack_big(sendbuf->buf + pos, sendbuf->len - pos - 4);
crypto_uint32_store_bigendian(sendbuf->buf + pos, sendbuf->len - pos - 4);
}

int packet_putisready(void) {
Expand Down
12 changes: 0 additions & 12 deletions uint32_pack_big.c

This file was deleted.

8 changes: 0 additions & 8 deletions uint32_pack_big.h

This file was deleted.

0 comments on commit edd5078

Please sign in to comment.