-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathr_stdlib.c
88 lines (67 loc) · 2.04 KB
/
r_stdlib.c
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
R_STDLIB.C - platform-specific C library routines for RSAEURO
Copyright (c) J.S.A.Kapp 1994 - 1996.
RSAEURO - RSA Library compatible with RSAREF(tm) 2.0.
All functions prototypes are the Same as for RSAREF(tm).
To aid compatiblity the source and the files follow the
same naming comventions that RSAREF(tm) uses. This should aid
direct importing to your applications.
This library is legal everywhere outside the US. And should
NOT be imported to the US and used there.
All Trademarks Acknowledged.
Secure Standard Library Routines.
Revision history
0.90 First revision, routines no longer rely on
ANSI Standard C provided routines as RSAREF(tm) does.
0.91 Second revision, minor improvements to orginal
code.
0.92 Current revision, modified to allow use of assembler
versions or the ANSI standard equivalent versions.
*/
#include "rsaeuro.h"
/* Library Copyright Message */
BYTE *Copyright[] = { "Copyright (c) J.S.A.Kapp 94-96." };
#ifndef USE_ANSI
/* Secure memset routine */
#ifndef USEASM
void R_memset(output, value, len)
POINTER output; /* output block */
int value; /* value */
unsigned int len; /* length of block */
{
if(len != 0) {
do {
*output++ = (unsigned char)value;
}while(--len != 0);
}
}
/* Secure memcpy routine */
void R_memcpy(output, input, len)
POINTER output; /* output block */
POINTER input; /* input block */
unsigned int len; /* length of blocks */
{
if (len != 0) {
do {
*output++ = *input++;
}while (--len != 0);
}
}
/* Secure memcmp routine */
int R_memcmp(Block1, Block2, len)
POINTER Block1; /* first block */
POINTER Block2; /* second block */
unsigned int len; /* length of blocks */
{
if(len != 0) {
/* little trick in declaring vars */
register const unsigned char *p1 = Block1, *p2 = Block2;
do {
if(*p1++ != *p2++)
return(*--p1 - *--p2);
}while(--len != 0);
}
return(0);
}
#endif /* USEASM */
#endif /* USE_ANSI */