Latest update.

This commit is contained in:
2018-10-06 20:10:24 +09:00
parent 20d4c774f6
commit 0148f33165
25 changed files with 393 additions and 152 deletions
+8 -1
View File
@@ -78,6 +78,7 @@
if ref $unified_info{generate}->{$src} eq "";
my $script = $unified_info{generate}->{$src}->[0];
$OUT .= generatesrc(src => $src,
product => $bin,
generator => $unified_info{generate}->{$src},
generator_incs => $unified_info{includes}->{$script},
generator_deps => $unified_info{depends}->{$script},
@@ -159,7 +160,13 @@
deps => [ resolvedepends($lib) ],
installed => is_installed($lib));
foreach (@{$unified_info{shared_sources}->{$lib}}) {
doobj($_, $lib, intent => "dso", installed => is_installed($lib));
# If this is somehow a compiled object, take care of it that way
# Otherwise, it might simply be generated
if (defined $unified_info{sources}->{$_}) {
doobj($_, $lib, intent => "dso", installed => is_installed($lib));
} else {
dogenerate($_, undef, $lib, intent => "dso");
}
}
$cache{$lib} = 1;
}
+20 -11
View File
@@ -758,9 +758,15 @@ reconfigure reconf :
if ($args{src} =~ /\.ld$/) {
(my $target = $args{src}) =~ s/\.ld$/.OPT/;
my $mkdef = sourcefile('util', 'mkdef.pl');
my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
my $ord_name =
$args{generator}->[1] || basename($args{product}, '.EXE');
my $case_insensitive =
$target{$args{intent}.'_cflags'} =~ m|/NAMES=[^/]*AS_IS|i
? '' : ' --case-insensitive';
return <<"EOF";
$target : $args{generator}->[0] $deps
\$(PERL) $mkdef --ordinals $args{generator}->[0] --name $args{generator}->[1] "--OS" "VMS" > $target
$target : $args{generator}->[0] $deps $mkdef
\$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name "--OS" "VMS"$case_insensitive > $target
EOF
} elsif ($target !~ /\.[sS]$/) {
my $target = $args{src};
@@ -925,7 +931,7 @@ EOF
grep { $_ =~ m|\.o$| }
@{$args{objs}};
my @defs = map { (my $x = $_) =~ s|\.ld$|.OPT|; $x }
grep { $_ =~ /\.ld$/ }
grep { $_ =~ m|\.ld$| }
@{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}});
die "More than one symbol vector" if scalar @defs > 1;
@@ -971,13 +977,16 @@ EOF
my $libd = dirname($lib);
my $libn = basename($lib);
(my $libn_nolib = $libn) =~ s/^lib//;
my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x }
grep { $_ =~ m|\.o$| }
@{$args{objs}};
my @defs = map { (my $x = $_) =~ s|\.ld$|.OPT|; $x }
grep { $_ =~ m|\.ld$| }
@{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}});
my $deps = join(", -\n\t\t", @objs, @deps);
my $deps = join(", -\n\t\t", @objs, @defs, @deps);
die "More than one symbol vector" if scalar @defs > 1;
my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
"VMS", "engine.opt")),
rel2abs($config{builddir}));
# The "[]" hack is because in .OPT files, each line inherits the
# previous line's file spec as default, so if no directory spec
# is present in the current line and the previous line has one that
@@ -994,12 +1003,12 @@ EOF
|| "\@ !";
return <<"EOF"
$lib.EXE : $deps
OPEN/WRITE/SHARE=READ OPT_FILE $lib.OPT
TYPE $engine_opt /OUTPUT=OPT_FILE:
OPEN/WRITE/SHARE=READ OPT_FILE $lib-components.OPT
$write_opt1
$write_opt2
CLOSE OPT_FILE
LINK \$(DSO_LDFLAGS)/SHARE=\$\@ $lib.OPT/OPT \$(DSO_EX_LIBS)
LINK \$(DSO_LDFLAGS)/SHARE=\$\@ $defs[0]/OPT,-
$lib-components.OPT/OPT \$(DSO_EX_LIBS)
- PURGE $lib.EXE,$lib.OPT,$lib.MAP
EOF
. ($config{target} =~ m|alpha| ? "" : <<"EOF"
+12 -5
View File
@@ -1001,9 +1001,12 @@ reconfigure reconf:
if ($args{src} =~ /\.ld$/) {
(my $target = $args{src}) =~ s/\.ld$/${defext}/;
(my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
my $ord_name =
$args{generator}->[1] || basename($args{product}, $dsoext);
return <<"EOF";
$target: $args{generator}->[0] $deps
\$(PERL) \$(SRCDIR)/util/mkdef.pl --ordinals $args{generator}->[0] --name $args{generator}->[1] --OS $mkdef_os > $target
$target: $args{generator}->[0] $deps \$(SRCDIR)/util/mkdef.pl
\$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS $mkdef_os > $target
EOF
} elsif ($args{src} !~ /\.[sS]$/) {
if ($args{generator}->[0] =~ m|^.*\.in$|) {
@@ -1222,14 +1225,18 @@ EOF
my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
grep { $_ !~ m/\.ld$/ }
@{$args{objs}};
my @defs = map { (my $x = $_) =~ s|\.ld$||; "$x$defext" }
grep { $_ =~ /\.ld$/ }
@{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}});
my $objs = join(" ", @objs);
my $deps = join(" ", @deps);
my $deps = join(" ", @objs, @defs, @deps);
my $target = dso($dso);
my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
return <<"EOF";
$target: $objs $deps
$target: $deps
\$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
-o $target $objs \\
-o $target$shared_def $objs \\
$linklibs \$(DSO_EX_LIBS)
EOF
}
+15 -10
View File
@@ -512,9 +512,12 @@ reconfigure reconf:
my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
"util", "mkdef.pl")),
rel2abs($config{builddir}));
my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
my $ord_name =
$args{generator}->[1] || basename($args{product}, $dsoext);
return <<"EOF";
$target: $args{generator}->[0] $deps
\$(PERL) $mkdef --ordinals $args{generator}->[0] --name $args{generator}->[1] --OS windows > $target
$target: $args{generator}->[0] $deps $mkdef
\$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
EOF
} elsif ($args{src} !~ /\.[sS]$/) {
my $target = $args{src};
@@ -670,20 +673,22 @@ EOF
my %args = @_;
my $dso = $args{lib};
my $dso_n = basename($dso);
my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
grep { $_ =~ m/\.(?:o|res)$/ }
@{$args{objs}};
my @defs = map { (my $x = $_) =~ s|\.ld$|$defext|; $x }
grep { $_ =~ /\.ld$/ }
@{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}});
my $objs = join("\n", @objs);
my $linklibs = join("", map { "$_\n" } @deps);
my $deps = join(" ", @objs, @deps);
my $deps = join(" ", @objs, @defs, @deps);
my $shared_def = join("", map { " /def:$_" } @defs);
return <<"EOF";
$dso$dsoext: $deps
IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
\$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
LIBRARY $dso_n
EXPORTS
bind_engine @1
v_check @2
<<
\$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
\$(LDOUTFLAG)$dso$dsoext$shared_def @<< || (DEL /Q \$(\@B).* $dso.* && EXIT 1)
$objs
$linklibs \$(DSO_EX_LIBS)
<<
+1 -1
View File
@@ -2079,7 +2079,7 @@ EOF
} elsif ($s =~ /\.ld$/) {
# We also recognise linker scripts (or corresponding)
# We know they are generated files
my $ld = cleanfile($buildd, $s, $blddir);
my $ld = cleanfile($buildd, $_, $blddir);
$unified_info{shared_sources}->{$ddest}->{$ld} = 1;
} else {
die "unrecognised source file type for shared library: $s\n";
+4 -4
View File
@@ -212,7 +212,7 @@ static int cipher_cleanup(EVP_CIPHER_CTX *ctx)
struct cipher_ctx *cipher_ctx =
(struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx);
if (ioctl(cipher_ctx->cfd, CIOCFSESSION, &cipher_ctx->sess) < 0) {
if (ioctl(cipher_ctx->cfd, CIOCFSESSION, &cipher_ctx->sess.ses) < 0) {
SYSerr(SYS_F_IOCTL, errno);
return 0;
}
@@ -255,7 +255,7 @@ static void prepare_cipher_methods()
sess.cipher = cipher_data[i].devcryptoid;
sess.keylen = cipher_data[i].keylen;
if (ioctl(cfd, CIOCGSESSION, &sess) < 0
|| ioctl(cfd, CIOCFSESSION, &sess) < 0)
|| ioctl(cfd, CIOCFSESSION, &sess.ses) < 0)
continue;
if ((known_cipher_methods[i] =
@@ -472,7 +472,7 @@ static int digest_final(EVP_MD_CTX *ctx, unsigned char *md)
SYSerr(SYS_F_IOCTL, errno);
return 0;
}
if (ioctl(digest_ctx->cfd, CIOCFSESSION, &digest_ctx->sess) < 0) {
if (ioctl(digest_ctx->cfd, CIOCFSESSION, &digest_ctx->sess.ses) < 0) {
SYSerr(SYS_F_IOCTL, errno);
return 0;
}
@@ -522,7 +522,7 @@ static void prepare_digest_methods()
*/
sess.mac = digest_data[i].devcryptoid;
if (ioctl(cfd, CIOCGSESSION, &sess) < 0
|| ioctl(cfd, CIOCFSESSION, &sess) < 0)
|| ioctl(cfd, CIOCFSESSION, &sess.ses) < 0)
continue;
if ((known_digest_methods[i] = EVP_MD_meth_new(digest_data[i].nid,
+1
View File
@@ -261,6 +261,7 @@ void openssl_add_all_ciphers_int(void)
EVP_add_cipher(EVP_chacha20());
# ifndef OPENSSL_NO_POLY1305
EVP_add_cipher(EVP_chacha20_poly1305());
EVP_add_cipher(EVP_chacha20_poly1305_draft());
# endif
#endif
}
+97 -31
View File
@@ -154,6 +154,7 @@ typedef struct {
struct { uint64_t aad, text; } len;
int aad, mac_inited, tag_len, nonce_len;
size_t tls_payload_length;
unsigned char draft:1;
} EVP_CHACHA_AEAD_CTX;
# define NO_TLS_PAYLOAD_LENGTH ((size_t)-1)
@@ -174,6 +175,7 @@ static int chacha20_poly1305_init_key(EVP_CIPHER_CTX *ctx,
actx->aad = 0;
actx->mac_inited = 0;
actx->tls_payload_length = NO_TLS_PAYLOAD_LENGTH;
actx->draft = 0;
if (iv != NULL) {
unsigned char temp[CHACHA_CTR_SIZE] = { 0 };
@@ -195,6 +197,27 @@ static int chacha20_poly1305_init_key(EVP_CIPHER_CTX *ctx,
return 1;
}
static int chacha20_poly1305_draft_init_key(EVP_CIPHER_CTX *ctx,
const unsigned char *inkey,
const unsigned char *iv, int enc)
{
EVP_CHACHA_AEAD_CTX *actx = aead_data(ctx);
if (!inkey)
return 1;
actx->len.aad = 0;
actx->len.text = 0;
actx->aad = 0;
actx->mac_inited = 0;
actx->tls_payload_length = NO_TLS_PAYLOAD_LENGTH;
actx->draft = 1;
chacha_init_key(ctx, inkey, NULL, enc);
return 1;
}
# if !defined(OPENSSL_SMALL_FOOTPRINT)
# if defined(POLY1305_ASM) && (defined(__x86_64) || defined(__x86_64__) || \
@@ -365,10 +388,11 @@ static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
{
EVP_CHACHA_AEAD_CTX *actx = aead_data(ctx);
size_t rem, plen = actx->tls_payload_length;
uint64_t thirteen = EVP_AEAD_TLS1_AAD_LEN;
if (!actx->mac_inited) {
# if !defined(OPENSSL_SMALL_FOOTPRINT)
if (plen != NO_TLS_PAYLOAD_LENGTH && out != NULL)
if (plen != NO_TLS_PAYLOAD_LENGTH && out != NULL && !actx->draft)
return chacha20_poly1305_tls_cipher(ctx, out, in, len);
# endif
actx->key.counter[0] = 0;
@@ -395,9 +419,14 @@ static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
return len;
} else { /* plain- or ciphertext */
if (actx->aad) { /* wrap up aad */
if ((rem = (size_t)actx->len.aad % POLY1305_BLOCK_SIZE))
Poly1305_Update(POLY1305_ctx(actx), zero,
POLY1305_BLOCK_SIZE - rem);
if (actx->draft) {
thirteen = actx->len.aad;
Poly1305_Update(POLY1305_ctx(actx), (const unsigned char *)&thirteen, sizeof(thirteen));
} else {
if ((rem = (size_t)actx->len.aad % POLY1305_BLOCK_SIZE))
Poly1305_Update(POLY1305_ctx(actx), zero,
POLY1305_BLOCK_SIZE - rem);
}
actx->aad = 0;
}
@@ -430,40 +459,52 @@ static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
} is_endian = { 1 };
unsigned char temp[POLY1305_BLOCK_SIZE];
if (actx->draft) {
thirteen = actx->len.text;
Poly1305_Update(POLY1305_ctx(actx), (const unsigned char *)&thirteen, sizeof(thirteen));
}
if (actx->aad) { /* wrap up aad */
if ((rem = (size_t)actx->len.aad % POLY1305_BLOCK_SIZE))
Poly1305_Update(POLY1305_ctx(actx), zero,
POLY1305_BLOCK_SIZE - rem);
if (actx->draft) {
thirteen = actx->len.aad;
Poly1305_Update(POLY1305_ctx(actx), (const unsigned char *)&thirteen, sizeof(thirteen));
} else {
if ((rem = (size_t)actx->len.aad % POLY1305_BLOCK_SIZE))
Poly1305_Update(POLY1305_ctx(actx), zero,
POLY1305_BLOCK_SIZE - rem);
}
actx->aad = 0;
}
if ((rem = (size_t)actx->len.text % POLY1305_BLOCK_SIZE))
Poly1305_Update(POLY1305_ctx(actx), zero,
POLY1305_BLOCK_SIZE - rem);
if (!actx->draft) {
if ((rem = (size_t)actx->len.text % POLY1305_BLOCK_SIZE))
Poly1305_Update(POLY1305_ctx(actx), zero,
POLY1305_BLOCK_SIZE - rem);
if (is_endian.little) {
Poly1305_Update(POLY1305_ctx(actx),
(unsigned char *)&actx->len, POLY1305_BLOCK_SIZE);
} else {
temp[0] = (unsigned char)(actx->len.aad);
temp[1] = (unsigned char)(actx->len.aad>>8);
temp[2] = (unsigned char)(actx->len.aad>>16);
temp[3] = (unsigned char)(actx->len.aad>>24);
temp[4] = (unsigned char)(actx->len.aad>>32);
temp[5] = (unsigned char)(actx->len.aad>>40);
temp[6] = (unsigned char)(actx->len.aad>>48);
temp[7] = (unsigned char)(actx->len.aad>>56);
if (is_endian.little) {
Poly1305_Update(POLY1305_ctx(actx),
(unsigned char *)&actx->len, POLY1305_BLOCK_SIZE);
} else {
temp[0] = (unsigned char)(actx->len.aad);
temp[1] = (unsigned char)(actx->len.aad>>8);
temp[2] = (unsigned char)(actx->len.aad>>16);
temp[3] = (unsigned char)(actx->len.aad>>24);
temp[4] = (unsigned char)(actx->len.aad>>32);
temp[5] = (unsigned char)(actx->len.aad>>40);
temp[6] = (unsigned char)(actx->len.aad>>48);
temp[7] = (unsigned char)(actx->len.aad>>56);
temp[8] = (unsigned char)(actx->len.text);
temp[9] = (unsigned char)(actx->len.text>>8);
temp[10] = (unsigned char)(actx->len.text>>16);
temp[11] = (unsigned char)(actx->len.text>>24);
temp[12] = (unsigned char)(actx->len.text>>32);
temp[13] = (unsigned char)(actx->len.text>>40);
temp[14] = (unsigned char)(actx->len.text>>48);
temp[15] = (unsigned char)(actx->len.text>>56);
temp[8] = (unsigned char)(actx->len.text);
temp[9] = (unsigned char)(actx->len.text>>8);
temp[10] = (unsigned char)(actx->len.text>>16);
temp[11] = (unsigned char)(actx->len.text>>24);
temp[12] = (unsigned char)(actx->len.text>>32);
temp[13] = (unsigned char)(actx->len.text>>40);
temp[14] = (unsigned char)(actx->len.text>>48);
temp[15] = (unsigned char)(actx->len.text>>56);
Poly1305_Update(POLY1305_ctx(actx), temp, POLY1305_BLOCK_SIZE);
Poly1305_Update(POLY1305_ctx(actx), temp, POLY1305_BLOCK_SIZE);
}
}
Poly1305_Final(POLY1305_ctx(actx), ctx->encrypt ? actx->tag
: temp);
@@ -533,12 +574,14 @@ static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
return 1;
case EVP_CTRL_AEAD_SET_IVLEN:
if (actx->draft) return -1;
if (arg <= 0 || arg > CHACHA_CTR_SIZE)
return 0;
actx->nonce_len = arg;
return 1;
case EVP_CTRL_AEAD_SET_IV_FIXED:
if (actx->draft) return -1;
if (arg != 12)
return 0;
actx->nonce[0] = actx->key.counter[1]
@@ -622,9 +665,32 @@ static EVP_CIPHER chacha20_poly1305 = {
NULL /* app_data */
};
static EVP_CIPHER chacha20_poly1305_draft = {
NID_chacha20_poly1305_draft,
1, /* block_size */
CHACHA_KEY_SIZE, /* key_len */
0, /* iv_len, none */
EVP_CIPH_FLAG_AEAD_CIPHER | EVP_CIPH_CUSTOM_IV |
EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT |
EVP_CIPH_CUSTOM_COPY | EVP_CIPH_FLAG_CUSTOM_CIPHER,
chacha20_poly1305_draft_init_key,
chacha20_poly1305_cipher,
chacha20_poly1305_cleanup,
0, /* 0 moves context-specific structure allocation to ctrl */
NULL, /* set_asn1_parameters */
NULL, /* get_asn1_parameters */
chacha20_poly1305_ctrl,
NULL /* app_data */
};
const EVP_CIPHER *EVP_chacha20_poly1305(void)
{
return(&chacha20_poly1305);
}
const EVP_CIPHER *EVP_chacha20_poly1305_draft(void)
{
return(&chacha20_poly1305_draft);
}
# endif
#endif
+23 -27
View File
@@ -20,12 +20,8 @@
#include <string.h>
/* e_os.h includes unistd.h, which defines _POSIX_VERSION */
#if !defined(OPENSSL_NO_SECURE_MEMORY) && defined(OPENSSL_SYS_UNIX) \
&& ( (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
|| defined(__sun) || defined(__hpux) || defined(__sgi) \
|| defined(__osf__) )
# define IMPLEMENTED
/* e_os.h defines OPENSSL_SECURE_MEMORY if secure memory can be implemented */
#ifdef OPENSSL_SECURE_MEMORY
# include <stdlib.h>
# include <assert.h>
# include <unistd.h>
@@ -51,7 +47,7 @@
# define MAP_ANON MAP_ANONYMOUS
#endif
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
static size_t secure_mem_used;
static int secure_mem_initialized;
@@ -71,7 +67,7 @@ static int sh_allocated(const char *ptr);
int CRYPTO_secure_malloc_init(size_t size, int minsize)
{
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
int ret = 0;
if (!secure_mem_initialized) {
@@ -89,12 +85,12 @@ int CRYPTO_secure_malloc_init(size_t size, int minsize)
return ret;
#else
return 0;
#endif /* IMPLEMENTED */
#endif /* OPENSSL_SECURE_MEMORY */
}
int CRYPTO_secure_malloc_done(void)
{
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
if (secure_mem_used == 0) {
sh_done();
secure_mem_initialized = 0;
@@ -102,22 +98,22 @@ int CRYPTO_secure_malloc_done(void)
sec_malloc_lock = NULL;
return 1;
}
#endif /* IMPLEMENTED */
#endif /* OPENSSL_SECURE_MEMORY */
return 0;
}
int CRYPTO_secure_malloc_initialized(void)
{
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
return secure_mem_initialized;
#else
return 0;
#endif /* IMPLEMENTED */
#endif /* OPENSSL_SECURE_MEMORY */
}
void *CRYPTO_secure_malloc(size_t num, const char *file, int line)
{
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
void *ret;
size_t actual_size;
@@ -132,12 +128,12 @@ void *CRYPTO_secure_malloc(size_t num, const char *file, int line)
return ret;
#else
return CRYPTO_malloc(num, file, line);
#endif /* IMPLEMENTED */
#endif /* OPENSSL_SECURE_MEMORY */
}
void *CRYPTO_secure_zalloc(size_t num, const char *file, int line)
{
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
if (secure_mem_initialized)
/* CRYPTO_secure_malloc() zeroes allocations when it is implemented */
return CRYPTO_secure_malloc(num, file, line);
@@ -147,7 +143,7 @@ void *CRYPTO_secure_zalloc(size_t num, const char *file, int line)
void CRYPTO_secure_free(void *ptr, const char *file, int line)
{
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
size_t actual_size;
if (ptr == NULL)
@@ -164,13 +160,13 @@ void CRYPTO_secure_free(void *ptr, const char *file, int line)
CRYPTO_THREAD_unlock(sec_malloc_lock);
#else
CRYPTO_free(ptr, file, line);
#endif /* IMPLEMENTED */
#endif /* OPENSSL_SECURE_MEMORY */
}
void CRYPTO_secure_clear_free(void *ptr, size_t num,
const char *file, int line)
{
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
size_t actual_size;
if (ptr == NULL)
@@ -191,12 +187,12 @@ void CRYPTO_secure_clear_free(void *ptr, size_t num,
return;
OPENSSL_cleanse(ptr, num);
CRYPTO_free(ptr, file, line);
#endif /* IMPLEMENTED */
#endif /* OPENSSL_SECURE_MEMORY */
}
int CRYPTO_secure_allocated(const void *ptr)
{
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
int ret;
if (!secure_mem_initialized)
@@ -207,21 +203,21 @@ int CRYPTO_secure_allocated(const void *ptr)
return ret;
#else
return 0;
#endif /* IMPLEMENTED */
#endif /* OPENSSL_SECURE_MEMORY */
}
size_t CRYPTO_secure_used(void)
{
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
return secure_mem_used;
#else
return 0;
#endif /* IMPLEMENTED */
#endif /* OPENSSL_SECURE_MEMORY */
}
size_t CRYPTO_secure_actual_size(void *ptr)
{
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
size_t actual_size;
CRYPTO_THREAD_write_lock(sec_malloc_lock);
@@ -239,7 +235,7 @@ size_t CRYPTO_secure_actual_size(void *ptr)
/*
* SECURE HEAP IMPLEMENTATION
*/
#ifdef IMPLEMENTED
#ifdef OPENSSL_SECURE_MEMORY
/*
@@ -647,4 +643,4 @@ static size_t sh_actual_size(char *ptr)
OPENSSL_assert(sh_testbit(ptr, list, sh.bittable));
return sh.arena_size / (ONE << list);
}
#endif /* IMPLEMENTED */
#endif /* OPENSSL_SECURE_MEMORY */
+6 -3
View File
@@ -1078,7 +1078,7 @@ static const unsigned char so[7762] = {
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0D, /* [ 7753] OBJ_hmacWithSHA512_256 */
};
#define NUM_NID 1195
#define NUM_NID 1196
static const ASN1_OBJECT nid_objs[NUM_NID] = {
{"UNDEF", "undefined", NID_undef},
{"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]},
@@ -2275,9 +2275,10 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = {
{"magma-mac", "magma-mac", NID_magma_mac},
{"hmacWithSHA512-224", "hmacWithSHA512-224", NID_hmacWithSHA512_224, 8, &so[7745]},
{"hmacWithSHA512-256", "hmacWithSHA512-256", NID_hmacWithSHA512_256, 8, &so[7753]},
{"ChaCha20-Poly1305-D", "chacha20-poly1305-draft", NID_chacha20_poly1305_draft },
};
#define NUM_SN 1186
#define NUM_SN 1187
static const unsigned int sn_objs[NUM_SN] = {
364, /* "AD_DVCS" */
419, /* "AES-128-CBC" */
@@ -2395,6 +2396,7 @@ static const unsigned int sn_objs[NUM_SN] = {
417, /* "CSPName" */
1019, /* "ChaCha20" */
1018, /* "ChaCha20-Poly1305" */
1195, /* "chacha20-poly1305-draft" */
367, /* "CrlID" */
391, /* "DC" */
31, /* "DES-CBC" */
@@ -3467,7 +3469,7 @@ static const unsigned int sn_objs[NUM_SN] = {
1093, /* "x509ExtAdmission" */
};
#define NUM_LN 1186
#define NUM_LN 1187
static const unsigned int ln_objs[NUM_LN] = {
363, /* "AD Time Stamping" */
405, /* "ANSI X9.62" */
@@ -3846,6 +3848,7 @@ static const unsigned int ln_objs[NUM_LN] = {
883, /* "certificateRevocationList" */
1019, /* "chacha20" */
1018, /* "chacha20-poly1305" */
1195, /* "ChaCha20-Poly1305-D" */
54, /* "challengePassword" */
407, /* "characteristic-two-field" */
395, /* "clearance" */
+1
View File
@@ -1192,3 +1192,4 @@ magma_cfb 1191
magma_mac 1192
hmacWithSHA512_224 1193
hmacWithSHA512_256 1194
chacha20_poly1305_draft 1195
+1
View File
@@ -1534,6 +1534,7 @@ sm-scheme 104 7 : SM4-CTR : sm4-ctr
: AES-192-CBC-HMAC-SHA256 : aes-192-cbc-hmac-sha256
: AES-256-CBC-HMAC-SHA256 : aes-256-cbc-hmac-sha256
: ChaCha20-Poly1305 : chacha20-poly1305
: ChaCha20-Poly1305-D : chacha20-poly1305-draft
: ChaCha20 : chacha20
ISO-US 10046 2 1 : dhpublicnumber : X9.42 DH
+10 -3
View File
@@ -317,8 +317,15 @@ struct servent *getservbyname(const char *name, const char *proto);
# endif
/* end vxworks */
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
# define CRYPTO_memcmp memcmp
#endif
# ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
# define CRYPTO_memcmp memcmp
# endif
/* unistd.h defines _POSIX_VERSION */
# if !defined(OPENSSL_NO_SECURE_MEMORY) && defined(OPENSSL_SYS_UNIX) \
&& ( (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
|| defined(__sun) || defined(__hpux) || defined(__sgi) \
|| defined(__osf__) )
# define OPENSSL_SECURE_MEMORY /* secure memory is implemented */
# endif
#endif
+20
View File
@@ -15,26 +15,46 @@ IF[{- !$disabled{"engine"} -}]
SOURCE[padlock]=e_padlock.c {- $target{padlock_asm_src} -}
DEPEND[padlock]=../libcrypto
INCLUDE[padlock]=../include
IF[{- defined $target{shared_defflag} -}]
SHARED_SOURCE[padlock]=padlock.ld
GENERATE[padlock.ld]=../util/engines.num
ENDIF
IF[{- !$disabled{capieng} -}]
ENGINES=capi
SOURCE[capi]=e_capi.c
DEPEND[capi]=../libcrypto
INCLUDE[capi]=../include
IF[{- defined $target{shared_defflag} -}]
SHARED_SOURCE[capi]=capi.ld
GENERATE[capi.ld]=../util/engines.num
ENDIF
ENDIF
IF[{- !$disabled{afalgeng} -}]
ENGINES=afalg
SOURCE[afalg]=e_afalg.c
DEPEND[afalg]=../libcrypto
INCLUDE[afalg]= ../include
IF[{- defined $target{shared_defflag} -}]
SHARED_SOURCE[afalg]=afalg.ld
GENERATE[afalg.ld]=../util/engines.num
ENDIF
ENDIF
ENGINES_NO_INST=ossltest dasync
SOURCE[dasync]=e_dasync.c
DEPEND[dasync]=../libcrypto
INCLUDE[dasync]=../include
IF[{- defined $target{shared_defflag} -}]
SHARED_SOURCE[dasync]=dasync.ld
GENERATE[dasync.ld]=../util/engines.num
ENDIF
SOURCE[ossltest]=e_ossltest.c
DEPEND[ossltest]=../libcrypto
INCLUDE[ossltest]=../include
IF[{- defined $target{shared_defflag} -}]
SHARED_SOURCE[ossltest]=ossltest.ld
GENERATE[ossltest.ld]=../util/engines.num
ENDIF
ENDIF
GENERATE[e_padlock-x86.s]=asm/e_padlock-x86.pl \
+1
View File
@@ -915,6 +915,7 @@ const EVP_CIPHER *EVP_camellia_256_ctr(void);
const EVP_CIPHER *EVP_chacha20(void);
# ifndef OPENSSL_NO_POLY1305
const EVP_CIPHER *EVP_chacha20_poly1305(void);
const EVP_CIPHER *EVP_chacha20_poly1305_draft(void);
# endif
# endif
+4
View File
@@ -4811,6 +4811,10 @@
#define LN_chacha20 "chacha20"
#define NID_chacha20 1019
#define SN_chacha20_poly1305_draft "ChaCha20-Poly1305-D"
#define LN_chacha20_poly1305_draft "chacha20-poly1305-draft"
#define NID_chacha20_poly1305_draft 1195
#define SN_dhpublicnumber "dhpublicnumber"
#define LN_dhpublicnumber "X9.42 DH"
#define NID_dhpublicnumber 920
+1
View File
@@ -125,6 +125,7 @@ extern "C" {
# define SSL_TXT_CAMELLIA256 "CAMELLIA256"
# define SSL_TXT_CAMELLIA "CAMELLIA"
# define SSL_TXT_CHACHA20 "CHACHA20"
# define SSL_TXT_CHACHA20_D "CHACHA20-D"
# define SSL_TXT_GOST "GOST89"
# define SSL_TXT_ARIA "ARIA"
# define SSL_TXT_ARIA_GCM "ARIAGCM"
+15 -2
View File
@@ -606,7 +606,12 @@ __owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain)
# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C09A
# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C09B
/* draft-ietf-tls-chacha20-poly1305-03 */
/* Chacha20-Poly1305-Draft ciphersuites from draft-agl-tls-chacha20poly1305-04 */
# define TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305_D 0x0300CC13
# define TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_D 0x0300CC14
# define TLS1_CK_DHE_RSA_WITH_CHACHA20_POLY1305_D 0x0300CC15
/* Chacha20-Poly1305 ciphersuites from RFC7905 */
# define TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305 0x0300CCA8
# define TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 0x0300CCA9
# define TLS1_CK_DHE_RSA_WITH_CHACHA20_POLY1305 0x0300CCAA
@@ -771,6 +776,9 @@ __owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain)
# define TLS1_RFC_DHE_RSA_WITH_CHACHA20_POLY1305 "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256"
# define TLS1_RFC_ECDHE_RSA_WITH_CHACHA20_POLY1305 "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"
# define TLS1_RFC_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"
# define TLS1_RFC_DHE_RSA_WITH_CHACHA20_POLY1305_D "OLD_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256"
# define TLS1_RFC_ECDHE_RSA_WITH_CHACHA20_POLY1305_D "OLD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"
# define TLS1_RFC_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_D "OLD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"
# define TLS1_RFC_PSK_WITH_CHACHA20_POLY1305 "TLS_PSK_WITH_CHACHA20_POLY1305_SHA256"
# define TLS1_RFC_ECDHE_PSK_WITH_CHACHA20_POLY1305 "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256"
# define TLS1_RFC_DHE_PSK_WITH_CHACHA20_POLY1305 "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256"
@@ -1099,7 +1107,12 @@ __owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain)
# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-RSA-CAMELLIA128-SHA256"
# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-RSA-CAMELLIA256-SHA384"
/* draft-ietf-tls-chacha20-poly1305-03 */
/* Chacha20-Poly1305-Draft ciphersuites from draft-agl-tls-chacha20poly1305-04 */
# define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305_D "ECDHE-RSA-CHACHA20-POLY1305-OLD"
# define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_D "ECDHE-ECDSA-CHACHA20-POLY1305-OLD"
# define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305_D "DHE-RSA-CHACHA20-POLY1305-OLD"
/* Chacha20-Poly1305 ciphersuites from RFC7905 */
# define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305 "ECDHE-RSA-CHACHA20-POLY1305"
# define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "ECDHE-ECDSA-CHACHA20-POLY1305"
# define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305 "DHE-RSA-CHACHA20-POLY1305"
+48
View File
@@ -2088,6 +2088,54 @@ static SSL_CIPHER ssl3_ciphers[] = {
256,
256,
},
{
1,
TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305_D,
TLS1_RFC_DHE_RSA_WITH_CHACHA20_POLY1305_D,
TLS1_CK_DHE_RSA_WITH_CHACHA20_POLY1305_D,
SSL_kDHE,
SSL_aRSA,
SSL_CHACHA20POLY1305_D,
SSL_AEAD,
TLS1_2_VERSION, TLS1_2_VERSION,
DTLS1_2_VERSION, DTLS1_2_VERSION,
SSL_HIGH,
SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
256,
256,
},
{
1,
TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305_D,
TLS1_RFC_ECDHE_RSA_WITH_CHACHA20_POLY1305_D,
TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305_D,
SSL_kECDHE,
SSL_aRSA,
SSL_CHACHA20POLY1305_D,
SSL_AEAD,
TLS1_2_VERSION, TLS1_2_VERSION,
DTLS1_2_VERSION, DTLS1_2_VERSION,
SSL_HIGH,
SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
256,
256,
},
{
1,
TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_D,
TLS1_RFC_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_D,
TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_D,
SSL_kECDHE,
SSL_aECDSA,
SSL_CHACHA20POLY1305_D,
SSL_AEAD,
TLS1_2_VERSION, TLS1_2_VERSION,
DTLS1_2_VERSION, DTLS1_2_VERSION,
SSL_HIGH,
SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
256,
256,
},
{
1,
TLS1_TXT_PSK_WITH_CHACHA20_POLY1305,
+8 -2
View File
@@ -43,7 +43,8 @@
#define SSL_ENC_CHACHA_IDX 19
#define SSL_ENC_ARIA128GCM_IDX 20
#define SSL_ENC_ARIA256GCM_IDX 21
#define SSL_ENC_NUM_IDX 22
#define SSL_ENC_CHACHA20_D_IDX 22
#define SSL_ENC_NUM_IDX 23
/* NB: make sure indices in these tables match values above */
@@ -76,6 +77,7 @@ static const ssl_cipher_table ssl_cipher_table_cipher[SSL_ENC_NUM_IDX] = {
{SSL_CHACHA20POLY1305, NID_chacha20_poly1305}, /* SSL_ENC_CHACHA_IDX 19 */
{SSL_ARIA128GCM, NID_aria_128_gcm}, /* SSL_ENC_ARIA128GCM_IDX 20 */
{SSL_ARIA256GCM, NID_aria_256_gcm}, /* SSL_ENC_ARIA256GCM_IDX 21 */
{SSL_CHACHA20POLY1305_D, NID_chacha20_poly1305_draft}, /* SSL_ENC_CHACHA20POLY1305_IDX 22 */
};
static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX];
@@ -274,6 +276,7 @@ static const SSL_CIPHER cipher_aliases[] = {
{0, SSL_TXT_CAMELLIA256, NULL, 0, 0, 0, SSL_CAMELLIA256},
{0, SSL_TXT_CAMELLIA, NULL, 0, 0, 0, SSL_CAMELLIA},
{0, SSL_TXT_CHACHA20, NULL, 0, 0, 0, SSL_CHACHA20},
{0, SSL_TXT_CHACHA20_D, NULL, 0, 0, 0, SSL_CHACHA20POLY1305_D},
{0, SSL_TXT_ARIA, NULL, 0, 0, 0, SSL_ARIA},
{0, SSL_TXT_ARIA_GCM, NULL, 0, 0, 0, SSL_ARIA128GCM | SSL_ARIA256GCM},
@@ -1868,6 +1871,9 @@ char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len)
case SSL_CHACHA20POLY1305:
enc = "CHACHA20/POLY1305(256)";
break;
case SSL_CHACHA20POLY1305_D:
enc = "CHACHA20/POLY1305-Draft(256)";
break;
default:
enc = "unknown";
break;
@@ -2192,7 +2198,7 @@ int ssl_cipher_get_overhead(const SSL_CIPHER *c, size_t *mac_overhead,
out = EVP_CCM_TLS_EXPLICIT_IV_LEN + 16;
} else if (c->algorithm_enc & (SSL_AES128CCM8 | SSL_AES256CCM8)) {
out = EVP_CCM_TLS_EXPLICIT_IV_LEN + 8;
} else if (c->algorithm_enc & SSL_CHACHA20POLY1305) {
} else if (c->algorithm_enc & (SSL_CHACHA20POLY1305 | SSL_CHACHA20POLY1305_D)) {
out = 16;
} else if (c->algorithm_mac & SSL_AEAD) {
/* We're supposed to have handled all the AEAD modes above */
+2 -1
View File
@@ -230,12 +230,13 @@
# define SSL_CHACHA20POLY1305 0x00080000U
# define SSL_ARIA128GCM 0x00100000U
# define SSL_ARIA256GCM 0x00200000U
# define SSL_CHACHA20POLY1305_D 0x00400000U
# define SSL_AESGCM (SSL_AES128GCM | SSL_AES256GCM)
# define SSL_AESCCM (SSL_AES128CCM | SSL_AES256CCM | SSL_AES128CCM8 | SSL_AES256CCM8)
# define SSL_AES (SSL_AES128|SSL_AES256|SSL_AESGCM|SSL_AESCCM)
# define SSL_CAMELLIA (SSL_CAMELLIA128|SSL_CAMELLIA256)
# define SSL_CHACHA20 (SSL_CHACHA20POLY1305)
# define SSL_CHACHA20 (SSL_CHACHA20POLY1305 | SSL_CHACHA20POLY1305_D)
# define SSL_ARIAGCM (SSL_ARIA128GCM | SSL_ARIA256GCM)
# define SSL_ARIA (SSL_ARIAGCM)
+6 -3
View File
@@ -10,13 +10,16 @@
#include <openssl/crypto.h>
#include "testutil.h"
#include "../e_os.h"
static int test_sec_mem(void)
{
#if defined(OPENSSL_SYS_LINUX) || defined(OPENSSL_SYS_UNIX)
#ifdef OPENSSL_SECURE_MEMORY
int testresult = 0;
char *p = NULL, *q = NULL, *r = NULL, *s = NULL;
TEST_info("Secure memory is implemented.");
s = OPENSSL_secure_malloc(20);
/* s = non-secure 20 */
if (!TEST_ptr(s)
@@ -124,6 +127,7 @@ static int test_sec_mem(void)
OPENSSL_secure_free(s);
return testresult;
#else
TEST_info("Secure memory is *not* implemented.");
/* Should fail. */
return TEST_false(CRYPTO_secure_malloc_init(4096, 32));
#endif
@@ -131,7 +135,7 @@ static int test_sec_mem(void)
static int test_sec_mem_clear(void)
{
#if defined(OPENSSL_SYS_LINUX) || defined(OPENSSL_SYS_UNIX)
#ifdef OPENSSL_SECURE_MEMORY
const int size = 64;
unsigned char *p = NULL;
int i, res = 0;
@@ -162,7 +166,6 @@ static int test_sec_mem_clear(void)
res = 1;
p = NULL;
err:
OPENSSL_secure_free(p);
CRYPTO_secure_malloc_done();
+2
View File
@@ -0,0 +1,2 @@
bind_engine 1 * EXIST::FUNCTION:
v_check 2 * EXIST::FUNCTION:
+1
View File
@@ -4577,3 +4577,4 @@ OCSP_resp_get0_respdata 4530 1_1_0j EXIST::FUNCTION:OCSP
EVP_MD_CTX_set_pkey_ctx 4531 1_1_1 EXIST::FUNCTION:
EVP_PKEY_meth_set_digest_custom 4532 1_1_1 EXIST::FUNCTION:
EVP_PKEY_meth_get_digest_custom 4533 1_1_1 EXIST::FUNCTION:
EVP_chacha20_poly1305_draft 4534 1_1_0 EXIST::FUNCTION:CHACHA,POLY1305_DRAFT
+86 -48
View File
@@ -23,15 +23,22 @@ use configdata;
my $name = undef; # internal library/module name
my $ordinals_file = undef; # the ordinals file to use
my $version = undef; # the version to use for the library
my $OS = undef; # the operating system family
my $verbose = 0;
my $ctest = 0;
# For VMS, some modules may have case insensitive names
my $case_insensitive = 0;
GetOptions('name=s' => \$name,
'ordinals=s' => \$ordinals_file,
'version=s' => \$version,
'OS=s' => \$OS,
'ctest' => \$ctest,
'verbose' => \$verbose)
'verbose' => \$verbose,
# For VMS
'case-insensitive' => \$case_insensitive)
or die "Error in command line arguments\n";
die "Please supply arguments\n"
@@ -231,20 +238,29 @@ sub sorter_linux {
sub writer_linux {
my $thisversion = '';
my $prevversion = '';
my $currversion_s = '';
my $prevversion_s = '';
my $indent = 0;
for (@_) {
if ($thisversion && $_->version() ne $thisversion) {
die "$ordinals_file: It doesn't make sense to have both versioned ",
"and unversioned symbols"
if $thisversion eq '*';
print <<"_____";
}$prevversion;
}${prevversion_s};
_____
$prevversion = " OPENSSL${SO_VARIANT}_$thisversion";
$prevversion_s = " OPENSSL${SO_VARIANT}_$thisversion";
$thisversion = ''; # Trigger start of next section
}
unless ($thisversion) {
$indent = 0;
$thisversion = $_->version();
$currversion_s = '';
$currversion_s = "OPENSSL${SO_VARIANT}_$thisversion "
if $thisversion ne '*';
print <<"_____";
OPENSSL${SO_VARIANT}_$thisversion {
${currversion_s}{
global:
_____
}
@@ -253,7 +269,7 @@ _____
print <<"_____";
local: *;
}$prevversion;
}${prevversion_s};
_____
}
@@ -278,36 +294,51 @@ _____
}
}
sub collect_VMS_mixedcase {
return [ 'SPARE', 'SPARE' ] unless @_;
my $s = shift;
my $s_uc = uc($s);
my $type = shift;
return [ "$s=$type", 'SPARE' ] if $s_uc eq $s;
return [ "$s_uc/$s=$type", "$s=$type" ];
}
sub collect_VMS_uppercase {
return [ 'SPARE' ] unless @_;
my $s = shift;
my $s_uc = uc($s);
my $type = shift;
return [ "$s_uc=$type" ];
}
sub writer_VMS {
my @slot_collection = ();
my $write_vector_slot_pair =
sub {
my $slot1 = shift;
my $slot2 = shift;
my $slotpair_text = " $slot1, -\n $slot2, -\n"
};
my $collector =
$case_insensitive ? \&collect_VMS_uppercase : \&collect_VMS_mixedcase;
my $last_num = 0;
foreach (@_) {
while (++$last_num < $_->number()) {
push @slot_collection, [ 'SPARE', 'SPARE' ];
push @slot_collection, $collector->(); # Just occupy a slot
}
my $type = {
FUNCTION => 'PROCEDURE',
VARIABLE => 'DATA'
} -> {$_->type()};
my $s = $_->name();
my $s_uc = uc($s);
if ($s_uc eq $s) {
push @slot_collection, [ "$s=$type", 'SPARE' ];
} else {
push @slot_collection, [ "$s_uc/$s=$type", "$s=$type" ];
}
push @slot_collection, $collector->($_->name(), $type);
}
print <<"_____";
IDENTIFICATION=$config{version}
print <<"_____" if defined $version;
IDENTIFICATION=$version
_____
print <<"_____" unless $case_insensitive;
CASE_SENSITIVE=YES
_____
print <<"_____";
SYMBOL_VECTOR=(-
_____
# It's uncertain how long aggregated lines the linker can handle,
@@ -317,18 +348,19 @@ _____
# can have more than one of those...
my $symvtextcount = 16; # The length of "SYMBOL_VECTOR=("
while (@slot_collection) {
my $pair = shift @slot_collection;
my $pairtextlength =
2 # one space indentation and comma
+ length($pair->[0])
+ 1 # postdent
+ 3 # two space indentation and comma
+ length($pair->[1])
+ 1 # postdent
;
my $set = shift @slot_collection;
my $settextlength = 0;
foreach (@$set) {
$settextlength +=
+ 3 # two space indentation and comma
+ length($_)
+ 1 # postdent
;
}
$settextlength--; # only one space indentation on the first one
my $firstcomma = ',';
if ($symvtextcount + $pairtextlength > 1024) {
if ($symvtextcount + $settextlength > 1024) {
print <<"_____";
)
SYMBOL_VECTOR=(-
@@ -338,30 +370,36 @@ _____
if ($symvtextcount == 16) {
$firstcomma = '';
}
print <<"_____";
$firstcomma$pair->[0] -
,$pair->[1] -
my $indent = ' '.$firstcomma;
foreach (@$set) {
print <<"_____";
$indent$_ -
_____
$symvtextcount += $pairtextlength;
$symvtextcount += length($indent) + length($_) + 1;
$indent = ' ,';
}
}
print <<"_____";
)
_____
my ($libvmajor, $libvminor, $libvedit, $libvpatch) =
$config{version} =~ /^(\d+)_(\d+)_(\d+)([a-z]{0,2})-.*$/;
my $libvpatchnum = 0;
for (split '', $libvpatch // '') {
$libvpatchnum += ord(lc($_)) - 96;
# To compensate because the letter 'z' is always followed by another,
# i.e. doesn't add any value on its own
$libvpatchnum-- if lc($_) eq 'z';
}
my $match1 = $libvmajor * 100 + $libvminor;
my $match2 = $libvedit * 100 + $libvpatchnum;
print <<"_____";
if (defined $version) {
my ($libvmajor, $libvminor, $libvedit, $libvpatch) =
$version =~ /^(\d+)_(\d+)_(\d+)([a-z]{0,2})(?:-.*)?$/;
my $libvpatchnum = 0;
for (split '', $libvpatch // '') {
$libvpatchnum += ord(lc($_)) - 96;
# To compensate because the letter 'z' is always followed by
# another, i.e. doesn't add any value on its own
$libvpatchnum-- if lc($_) eq 'z';
}
my $match1 = $libvmajor * 100 + $libvminor;
my $match2 = $libvedit * 100 + $libvpatchnum;
print <<"_____";
GSMATCH=LEQUAL,$match1,$match2
_____
}
}
sub writer_ctest {