projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix ecdsatest.c.
[oweals/openssl.git]
/
apps
/
enc.c
diff --git
a/apps/enc.c
b/apps/enc.c
index ea948f8d101b3d958861584c5bb65106fe779b58..8beb2dff35bee2be83337def4499ffe21c142244 100644
(file)
--- a/
apps/enc.c
+++ b/
apps/enc.c
@@
-100,9
+100,6
@@
int MAIN(int, char **);
int MAIN(int argc, char **argv)
{
int MAIN(int argc, char **argv)
{
-#ifndef OPENSSL_NO_ENGINE
- ENGINE *e = NULL;
-#endif
static const char magic[]="Salted__";
char mbuf[sizeof magic-1];
char *strbuf=NULL;
static const char magic[]="Salted__";
char mbuf[sizeof magic-1];
char *strbuf=NULL;
@@
-127,6
+124,7
@@
int MAIN(int argc, char **argv)
char *engine = NULL;
#endif
const EVP_MD *dgst=NULL;
char *engine = NULL;
#endif
const EVP_MD *dgst=NULL;
+ int non_fips_allow = 0;
apps_startup();
apps_startup();
@@
-225,7
+223,12
@@
int MAIN(int argc, char **argv)
goto bad;
}
buf[0]='\0';
goto bad;
}
buf[0]='\0';
- fgets(buf,sizeof buf,infile);
+ if (!fgets(buf,sizeof buf,infile))
+ {
+ BIO_printf(bio_err,"unable to read key from '%s'\n",
+ file);
+ goto bad;
+ }
fclose(infile);
i=strlen(buf);
if ((i > 0) &&
fclose(infile);
i=strlen(buf);
if ((i > 0) &&
@@
-261,6
+264,8
@@
int MAIN(int argc, char **argv)
if (--argc < 1) goto bad;
md= *(++argv);
}
if (--argc < 1) goto bad;
md= *(++argv);
}
+ else if (strcmp(*argv,"-non-fips-allow") == 0)
+ non_fips_allow = 1;
else if ((argv[0][0] == '-') &&
((c=EVP_get_cipherbyname(&(argv[0][1]))) != NULL))
{
else if ((argv[0][0] == '-') &&
((c=EVP_get_cipherbyname(&(argv[0][1]))) != NULL))
{
@@
-303,7
+308,7
@@
bad:
}
#ifndef OPENSSL_NO_ENGINE
}
#ifndef OPENSSL_NO_ENGINE
-
e =
setup_engine(bio_err, engine, 0);
+ setup_engine(bio_err, engine, 0);
#endif
if (md && (dgst=EVP_get_digestbyname(md)) == NULL)
#endif
if (md && (dgst=EVP_get_digestbyname(md)) == NULL)
@@
-314,7
+319,10
@@
bad:
if (dgst == NULL)
{
if (dgst == NULL)
{
- dgst = EVP_md5();
+ if (in_FIPS_mode)
+ dgst = EVP_sha1();
+ else
+ dgst = EVP_md5();
}
if (bufsize != NULL)
}
if (bufsize != NULL)
@@
-340,7
+348,7
@@
bad:
}
/* It must be large enough for a base64 encoded line */
}
/* It must be large enough for a base64 encoded line */
- if (n < 80) n=80;
+ if (
base64 &&
n < 80) n=80;
bsize=(int)n;
if (verbose) BIO_printf(bio_err,"bufsize=%d\n",bsize);
bsize=(int)n;
if (verbose) BIO_printf(bio_err,"bufsize=%d\n",bsize);
@@
-365,12
+373,16
@@
bad:
{
BIO_set_callback(in,BIO_debug_callback);
BIO_set_callback(out,BIO_debug_callback);
{
BIO_set_callback(in,BIO_debug_callback);
BIO_set_callback(out,BIO_debug_callback);
- BIO_set_callback_arg(in,bio_err);
- BIO_set_callback_arg(out,bio_err);
+ BIO_set_callback_arg(in,
(char *)
bio_err);
+ BIO_set_callback_arg(out,
(char *)
bio_err);
}
if (inf == NULL)
}
if (inf == NULL)
+ {
+ if (bufsize != NULL)
+ setvbuf(stdin, (char *)NULL, _IONBF, 0);
BIO_set_fp(in,stdin,BIO_NOCLOSE);
BIO_set_fp(in,stdin,BIO_NOCLOSE);
+ }
else
{
if (BIO_read_filename(in,inf) <= 0)
else
{
if (BIO_read_filename(in,inf) <= 0)
@@
-421,6
+433,8
@@
bad:
if (outf == NULL)
{
BIO_set_fp(out,stdout,BIO_NOCLOSE);
if (outf == NULL)
{
BIO_set_fp(out,stdout,BIO_NOCLOSE);
+ if (bufsize != NULL)
+ setvbuf(stdout, (char *)NULL, _IONBF, 0);
#ifdef OPENSSL_SYS_VMS
{
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
#ifdef OPENSSL_SYS_VMS
{
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
@@
-447,7
+461,7
@@
bad:
if (debug)
{
BIO_set_callback(b64,BIO_debug_callback);
if (debug)
{
BIO_set_callback(b64,BIO_debug_callback);
- BIO_set_callback_arg(b64,bio_err);
+ BIO_set_callback_arg(b64,
(char *)
bio_err);
}
if (olb64)
BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL);
}
if (olb64)
BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL);
@@
-521,7
+535,8
@@
bad:
BIO_printf(bio_err,"invalid hex iv value\n");
goto end;
}
BIO_printf(bio_err,"invalid hex iv value\n");
goto end;
}
- if ((hiv == NULL) && (str == NULL))
+ if ((hiv == NULL) && (str == NULL)
+ && EVP_CIPHER_iv_length(cipher) != 0)
{
/* No IV was explicitly set and no IV was generated
* during EVP_BytesToKey. Hence the IV is undefined,
{
/* No IV was explicitly set and no IV was generated
* during EVP_BytesToKey. Hence the IV is undefined,
@@
-543,6
+558,11
@@
bad:
*/
BIO_get_cipher_ctx(benc, &ctx);
*/
BIO_get_cipher_ctx(benc, &ctx);
+
+ if (non_fips_allow)
+ EVP_CIPHER_CTX_set_flags(ctx,
+ EVP_CIPH_FLAG_NON_FIPS_ALLOW);
+
if (!EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, enc))
{
BIO_printf(bio_err, "Error setting cipher %s\n",
if (!EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, enc))
{
BIO_printf(bio_err, "Error setting cipher %s\n",
@@
-565,7
+585,7
@@
bad:
if (debug)
{
BIO_set_callback(benc,BIO_debug_callback);
if (debug)
{
BIO_set_callback(benc,BIO_debug_callback);
- BIO_set_callback_arg(benc,bio_err);
+ BIO_set_callback_arg(benc,
(char *)
bio_err);
}
if (printkey)
}
if (printkey)