aboutsummaryrefslogtreecommitdiff
path: root/openssl/trunk/crypto/ecdsa/ecs_err.c
blob: 90f1942e79fd1d59f9b38c052b228f46ec7109ff (plain) (blame)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* crypto/ecdsa/ecs_err.c */
/* ====================================================================
 * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

/* NOTE: this file was auto generated by the mkerr.pl script: any changes
 * made to it will be overwritten when the script next updates this file,
 * only reason strings will be preserved.
 */

#include <stdio.h>
#include <openssl/err.h>
#include <openssl/ecdsa.h>

/* BEGIN ERROR CODES */
#ifndef OPENSSL_NO_ERR

#define ERR_FUNC(func) ERR_PACK(ERR_LIB_ECDSA,func,0)
#define ERR_REASON(reason) ERR_PACK(ERR_LIB_ECDSA,0,reason)

static ERR_STRING_DATA ECDSA_str_functs[]=
	{
{ERR_FUNC(ECDSA_F_ECDSA_DATA_NEW_METHOD),	"ECDSA_DATA_new_method"},
{ERR_FUNC(ECDSA_F_ECDSA_DO_SIGN),	"ECDSA_do_sign"},
{ERR_FUNC(ECDSA_F_ECDSA_DO_VERIFY),	"ECDSA_do_verify"},
{ERR_FUNC(ECDSA_F_ECDSA_SIGN_SETUP),	"ECDSA_sign_setup"},
{0,NULL}
	};

static ERR_STRING_DATA ECDSA_str_reasons[]=
	{
{ERR_REASON(ECDSA_R_BAD_SIGNATURE)       ,"bad signature"},
{ERR_REASON(ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"},
{ERR_REASON(ECDSA_R_ERR_EC_LIB)          ,"err ec lib"},
{ERR_REASON(ECDSA_R_MISSING_PARAMETERS)  ,"missing parameters"},
{ERR_REASON(ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED),"random number generation failed"},
{ERR_REASON(ECDSA_R_SIGNATURE_MALLOC_FAILED),"signature malloc failed"},
{0,NULL}
	};

#endif

void ERR_load_ECDSA_strings(void)
	{
	static int init=1;

	if (init)
		{
		init=0;
#ifndef OPENSSL_NO_ERR
		ERR_load_strings(0,ECDSA_str_functs);
		ERR_load_strings(0,ECDSA_str_reasons);
#endif

		}
	}
an>): class DockerError(Exception): "Docker returned failure." def __init__(self, *args, **kwargs): super(Docker, self).__init__(("docker",) + args, **kwargs) def __enter__(self): return self def __exit__(self, *oops): if any(oops): return if self.stdin: self.stdin.close() status = self.wait() if status: raise self.DockerError() # Filter which acts like fakeroot for tarfile.TarFile.add() def fakeroot_filter(info): info.uname = info.gname = "root" info.uid = info.gid = 0 return info # Commands @cmd(arg("--dist", default = "jessie", help = "distribution for base docker image"), arg("--tag", default = "baiji:jessie", help = "tag to use for constructed base docker image"), ) def create(args): """ Construct a base Docker image. This is mostly just the output of debootstrap, with a bit of extra setup to include git, build-essentials, and fakeroot. """ with tempdir() as dn: subprocess.check_call(("fakeroot", "/usr/sbin/debootstrap", "--foreign", "--variant=buildd", args.dist, dn)) with Docker("import", "-", args.tag, stdin = subprocess.PIPE) as docker: with tarfile.open(mode = "w|", fileobj = docker.stdin) as tar: tar.add(dn, ".", filter = fakeroot_filter) with Docker("build", "-t", args.tag, "-", stdin = subprocess.PIPE) as docker: docker.communicate(textwrap.dedent('''\ FROM {args.tag} RUN sed -i '/mount -t proc /d; /mount -t sysfs /d' /debootstrap/functions && \\ /debootstrap/debootstrap --second-stage RUN apt-get update && \\ apt-get install -y --no-install-recommends build-essential fakeroot git apt-utils RUN useradd -U -m -d /build baiji WORKDIR /build '''.format(args = args))) @cmd(arg("--tag", default = "baiji:jessie", help = "tag of base docker image to update"), ) def update(args): """ Update a base Docker image. """ with Docker("build", "-t", args.tag, "-", stdin = subprocess.PIPE) as docker: docker.communicate(textwrap.dedent('''\ FROM {args.tag} RUN apt-get update && \\ apt-get upgrade -y --with-new-pkgs --no-install-recommends && \\ apt-get autoremove && \\ apt-get clean '''.format(args = args))) @cmd(arg("--tag", default = "baiji:jessie", help = "tag of base docker image to use"), arg("--dsc", type = argparse.FileType("r"), help = ".dsc file to build"), arg("--local-package", default = [], nargs = "+", help = "local packages to make available to build"), arg("--force-image", action = "store_true", help = "don't rebuild Docker image"), arg("--dont-clean", action = "store_true", help = "don't clean up old Docker images"), arg("--just-image", action = "store_true", help = "don't build, just generate Docker image"), ) def build(args): """ Build a binary package given a source package. If no source package supplied, try to build one from the current directory, like debuild. """ if args.dsc is None: try: subprocess.check_call(("dpkg-buildpackage", "-S", "-us", "-uc", "-rfakeroot")) except Exception as e: sys.exit("Couldn't build source package: {!s}".format(e)) try: with open("debian/changelog") as f: changelog = debian.changelog.Changelog(f) args.dsc = open("../{}_{}{}.dsc".format( changelog.package, changelog.upstream_version, "" if changelog.debian_revision is None else "-" + changelog.debian_revision)) except Exception as e: sys.exit("Couldn't find .dsc file: {!s}".format(e)) dsc = debian.deb822.Dsc(args.dsc) dummy = debian.deb822.Deb822() dummy_name = "baiji-depends-" + dsc["Source"] dummy_fn = "{}_{}_all.deb".format(dummy_name, dsc["Version"]) dummy["Depends"] = ", ".join(dsc[i] for i in ("Build-Depends", "Build-Depends-Indep", "Build-Depends-Arch") if i in dsc) dummy["Package"] = dummy_name for tag in ("Version", "Maintainer", "Homepage"): dummy[tag] = dsc[tag] build_image_hash = hashlib.sha1(dummy["Depends"]).hexdigest() build_image_name = "baiji/build/{}".format(dsc["Source"]) build_image_vers = "{}-{}".format(dsc["Version"], build_image_hash) build_image = "{}:{}".format(build_image_name, build_image_vers) with Docker("image", "ls", build_image_name, "--format", "{{.Tag}}", stdout = subprocess.PIPE) as docker: build_image_versions = set(docker.stdout.read().split()) build_image_exists = build_image_vers in build_image_versions make_build_image = args.force_image or not build_image_exists if args.dont_clean: build_image_versions = { build_image_vers } if build_image_exists else set() if not make_build_image: build_image_versions.discard(build_image_vers) for v in build_image_versions: with Docker("rmi", "{}:{}".format(build_image_name, v)): pass if make_build_image: with tempdir() as dn: equivs = subprocess.Popen(("equivs-build", "/dev/stdin"), stdin = subprocess.PIPE, stdout = subprocess.PIPE, cwd = dn) equivs.communicate(str(dummy)) if equivs.wait(): sys.exit("Couldn't generate dummy dependency package") with open(os.path.join(dn, "Dockerfile"), "w") as f: f.write(textwrap.dedent('''\ FROM {args.tag} COPY build.sh /baiji/ COPY micro-apt /micro-apt/ RUN cd /micro-apt && \\ apt-ftparchive packages . > Packages RUN cd /etc/apt/sources.list.d && \\ echo 'deb [trusted=yes] file:///micro-apt ./' > micro-apt.list RUN apt-get update && \\ apt-get install -y --no-install-recommends {dummy_name} && \\ apt-get clean USER baiji '''.format(args = args, dummy_name = dummy_name))) with open(os.path.join(dn, "build.sh"), "w") as f: f.write(textwrap.dedent('''\ #!/bin/bash - set -eo pipefail arch=`dpkg-architecture -qDEB_BUILD_ARCH` dpkg-source -x /source/{source}_{version}.dsc cd {source}-{version} dpkg-buildpackage -b -uc -us 2>&1 | tee ../{source}_{version}_$arch.build cd .. rm -rf {source}-{version} '''.format(source = dsc["Source"], version = dsc["Version"]))) with Docker("build", "-t", build_image, "-", stdin = subprocess.PIPE) as docker: with tarfile.open(mode = "w|", fileobj = docker.stdin) as tar: for fn in ("Dockerfile", "build.sh"): tar.add(os.path.join(dn, fn), fn, filter = fakeroot_filter) for pkg in [os.path.join(dn, dummy_fn)] + args.local_package: tar.add(pkg, os.path.join("micro-apt", os.path.basename(pkg)), filter = fakeroot_filter) if not args.just_image: container_name = "baiji-build-{}".format(dsc["Source"]) dn = os.path.dirname(args.dsc.name) with Docker("run", "-i", "--name", container_name, "--network", "none", "-v", "{}:/source:ro".format(os.path.abspath(dn)), build_image, "/bin/bash", "-x", "/baiji/build.sh"): pass with Docker("cp", "{}:/build/.".format(container_name), "-", stdout = subprocess.PIPE) as docker: with tarfile.open(mode = "r|*", fileobj = docker.stdout) as tar: for member in tar: fn = os.path.basename(member.name) if any(fn.endswith(fn2) for fn2 in (".deb", ".changes")): with open(os.path.join(dn, fn), "w") as f: f.write(tar.extractfile(member).read()) with Docker("rm", container_name): pass # Parse arguments and dispatch to one of the commands above. def main(): HF = type("HF", (argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter), {}) parser = argparse.ArgumentParser(formatter_class = HF, description = __doc__) subparsers = parser.add_subparsers(title = "Commands", metavar = "") for name in sorted(globals()): func = globals()[name] try: setup_parser = func._setup_parser except: continue setup_parser(subparsers.add_parser(name.replace("_", "-"), formatter_class = HF, description = func.__doc__, help = (func.__doc__ or "").lstrip().partition("\n")[0])) args = parser.parse_args() args.func(args) if __name__ == "__main__": main()