File: byte.c

package info (click to toggle)
tinyssh 20250501-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,388 kB
  • sloc: ansic: 20,245; sh: 1,582; python: 1,449; makefile: 913
file content (37 lines) | stat: -rw-r--r-- 710 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
20241205
*/

#include "crypto_int16.h"
#include "byte.h"

void byte_copy(void *yv, long long ylen, const void *xv) {

    long long i;
    const char *x = xv;
    char *y = yv;

    for (i = 0; i < ylen; ++i) y[i] = x[i];
}

int byte_isequal(const void *yv, long long ylen, const void *xv) {

    long long i;
    const unsigned char *y = yv;
    const unsigned char *x = xv;
    unsigned char diff = 0;

    for (i = 0; i < ylen; ++i) diff |= x[i] ^ y[i];
    return crypto_int16_zero_01(diff);
}

void byte_zero(void *yv, long long ylen) {

    long long i;
    volatile char *y = yv;

    for (i = 0; i < ylen; ++i) y[i] = 0;
#ifdef __GNUC__
    __asm__ __volatile__("" : : "r"(yv) : "memory");
#endif
}