projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rc4/asm/rc4-586.pl: allow for 386-only build.
[oweals/openssl.git]
/
crypto
/
evp
/
encode.c
diff --git
a/crypto/evp/encode.c
b/crypto/evp/encode.c
index 110435d5dfc4911e4155c01d50872550026b9039..28546a84bc2b61e4150af841d264a9d66386c52a 100644
(file)
--- a/
crypto/evp/encode.c
+++ b/
crypto/evp/encode.c
@@
-85,7
+85,7
@@
#define CHUNKS_PER_LINE (64/4)
#define CHAR_PER_LINE (64+1)
#define CHUNKS_PER_LINE (64/4)
#define CHAR_PER_LINE (64+1)
-static unsigned char data_bin2ascii[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZ\
+static
const
unsigned char data_bin2ascii[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz0123456789+/";
/* 0xF0 is a EOLN
abcdefghijklmnopqrstuvwxyz0123456789+/";
/* 0xF0 is a EOLN
@@
-102,7
+102,7
@@
abcdefghijklmnopqrstuvwxyz0123456789+/";
#define B64_ERROR 0xFF
#define B64_NOT_BASE64(a) (((a)|0x13) == 0xF3)
#define B64_ERROR 0xFF
#define B64_NOT_BASE64(a) (((a)|0x13) == 0xF3)
-static unsigned char data_ascii2bin[128]={
+static
const
unsigned char data_ascii2bin[128]={
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xE0,0xF0,0xFF,0xFF,0xF1,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xE0,0xF0,0xFF,0xFF,0xF1,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
@@
-129,13
+129,14
@@
void EVP_EncodeInit(EVP_ENCODE_CTX *ctx)
}
void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
}
void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
- unsigned char *in, int inl)
+
const
unsigned char *in, int inl)
{
int i,j;
unsigned int total=0;
*outl=0;
if (inl == 0) return;
{
int i,j;
unsigned int total=0;
*outl=0;
if (inl == 0) return;
+ OPENSSL_assert(ctx->length <= (int)sizeof(ctx->enc_data));
if ((ctx->num+inl) < ctx->length)
{
memcpy(&(ctx->enc_data[ctx->num]),in,inl);
if ((ctx->num+inl) < ctx->length)
{
memcpy(&(ctx->enc_data[ctx->num]),in,inl);
@@
-185,7
+186,7
@@
void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl)
*outl=ret;
}
*outl=ret;
}
-int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int dlen)
+int EVP_EncodeBlock(unsigned char *t,
const
unsigned char *f, int dlen)
{
int i,ret=0;
unsigned long l;
{
int i,ret=0;
unsigned long l;
@@
-232,9
+233,9
@@
void EVP_DecodeInit(EVP_ENCODE_CTX *ctx)
* 1 for full line
*/
int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
* 1 for full line
*/
int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
- unsigned char *in, int inl)
+
const
unsigned char *in, int inl)
{
{
- int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,
tmp2,
exp_nl;
+ int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,exp_nl;
unsigned char *d;
n=ctx->num;
unsigned char *d;
n=ctx->num;
@@
-258,6
+259,7
@@
int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
/* only save the good data :-) */
if (!B64_NOT_BASE64(v))
{
/* only save the good data :-) */
if (!B64_NOT_BASE64(v))
{
+ OPENSSL_assert(n < (int)sizeof(ctx->enc_data));
d[n++]=tmp;
ln++;
}
d[n++]=tmp;
ln++;
}
@@
-277,6
+279,13
@@
int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
eof++;
}
eof++;
}
+ if (v == B64_CR)
+ {
+ ln = 0;
+ if (exp_nl)
+ continue;
+ }
+
/* eoln */
if (v == B64_EOLN)
{
/* eoln */
if (v == B64_EOLN)
{
@@
-292,20
+301,29
@@
int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
/* If we are at the end of input and it looks like a
* line, process it. */
if (((i+1) == inl) && (((n&3) == 0) || eof))
/* If we are at the end of input and it looks like a
* line, process it. */
if (((i+1) == inl) && (((n&3) == 0) || eof))
+ {
v=B64_EOF;
v=B64_EOF;
+ /* In case things were given us in really small
+ records (so two '=' were given in separate
+ updates), eof may contain the incorrect number
+ of ending bytes to skip, so let's redo the count */
+ eof = 0;
+ if (d[n-1] == '=') eof++;
+ if (d[n-2] == '=') eof++;
+ /* There will never be more than two '=' */
+ }
- if ((v == B64_EOF
) || (n >= 68
))
+ if ((v == B64_EOF
&& (n&3) == 0) || (n >= 64
))
{
/* This is needed to work correctly on 64 byte input
* lines. We process the line and then need to
* accept the '\n' */
{
/* This is needed to work correctly on 64 byte input
* lines. We process the line and then need to
* accept the '\n' */
- if ((v != B64_EOF) && (n >= 68)) exp_nl=1;
- tmp2=v;
+ if ((v != B64_EOF) && (n >= 64)) exp_nl=1;
if (n > 0)
{
v=EVP_DecodeBlock(out,d,n);
if (n > 0)
{
v=EVP_DecodeBlock(out,d,n);
- if (v < 0) { rv=0; goto end; }
n=0;
n=0;
+ if (v < 0) { rv=0; goto end; }
ret+=(v-eof);
}
else
ret+=(v-eof);
}
else
@@
-337,7
+355,7
@@
end:
return(rv);
}
return(rv);
}
-int EVP_DecodeBlock(unsigned char *t, unsigned char *f, int n)
+int EVP_DecodeBlock(unsigned char *t,
const
unsigned char *f, int n)
{
int i,ret=0,a,b,c,d;
unsigned long l;
{
int i,ret=0,a,b,c,d;
unsigned long l;