From 110755e9d4f26f376548dcf3c8d34db4f96fc66e Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Fri, 10 Nov 2017 11:57:16 +0200 Subject: [PATCH] remove sha512_t our libmd never shipped SHA512_t_*, but pkg build happened to succeed because -zdefs was not on by default. fun fact: some of the tests tried to import 'pkg.sha512' which didn't exist; the module was called 'pkg.sha512_t'. --- src/modules/digest.py | 36 +---- src/modules/sha512_t.c | 272 -------------------------------------- src/pkg/manifests/package:pkg.p5m | 2 - src/setup.py | 23 ---- src/tests/api/t_sha512_t.py | 139 ------------------- src/tests/cli/t_pkg_install.py | 9 -- src/tests/cli/t_pkg_revert.py | 25 +--- src/tests/cli/t_pkg_search.py | 18 --- src/tests/cli/t_pkg_sysrepo.py | 33 +---- src/tests/cli/t_pkgrecv.py | 8 -- src/tests/cli/t_pkgrepo.py | 10 -- src/tests/cli/t_pkgsend.py | 9 -- src/tests/cli/t_pkgsign.py | 10 -- 13 files changed, 6 insertions(+), 588 deletions(-) delete mode 100644 src/modules/sha512_t.c delete mode 100644 src/tests/api/t_sha512_t.py diff --git a/src/modules/digest.py b/src/modules/digest.py index a311791f..83ba45fb 100644 --- a/src/modules/digest.py +++ b/src/modules/digest.py @@ -25,11 +25,6 @@ # import hashlib -try: - import pkg.sha512_t - sha512_supported = True -except ImportError: - sha512_supported = False # When running the test suite, we alter our behaviour depending on certain # debug flags. @@ -75,16 +70,8 @@ DEFAULT_HASH_NAME = "sha-1" # using the "most preferred" hash. See get_preferred_hash(..), # get_least_preferred_hash(..) and get_common_preferred_hash(..) # -if DebugValues["hash"] == "sha1+sha512_256" and sha512_supported: - # Simulate pkg(5) where SHA-1 and SHA-512/256 are used for publication - DEFAULT_HASH_ATTRS = ["hash", "pkg.hash.sha512_256"] - DEFAULT_CHASH_ATTRS = ["chash", "pkg.chash.sha512_256"] - DEFAULT_CONTENT_HASH_ATTRS = ["elfhash", "pkg.content-hash.sha512_256"] - DEFAULT_CHAIN_ATTRS = ["chain", "pkg.chain.sha512_256"] - DEFAULT_CHAIN_CHASH_ATTRS = ["chain.chashes", - "pkg.chain.chashes.sha512_256"] -elif DebugValues["hash"] == "sha1+sha256": +if DebugValues["hash"] == "sha1+sha256": # Simulate pkg(5) where SHA-1 and SHA-256 are used for publication DEFAULT_HASH_ATTRS = ["hash", "pkg.hash.sha256"] DEFAULT_CHASH_ATTRS = ["chash", "pkg.chash.sha256"] @@ -93,14 +80,6 @@ elif DebugValues["hash"] == "sha1+sha256": DEFAULT_CHAIN_CHASH_ATTRS = ["chain.chashes", "pkg.chain.chashes.sha256"] -elif DebugValues["hash"] == "sha512_256" and sha512_supported: - # Simulate pkg(5) where SHA-1 is no longer used for publication - DEFAULT_HASH_ATTRS = ["pkg.hash.sha512_256"] - DEFAULT_CHASH_ATTRS = ["pkg.chash.sha512_256"] - DEFAULT_CONTENT_HASH_ATTRS = ["pkg.content-hash.sha512_256"] - DEFAULT_CHAIN_ATTRS = ["pkg.chain.sha512_256"] - DEFAULT_CHAIN_CHASH_ATTRS = ["pkg.chain.chashes.sha512_256"] - elif DebugValues["hash"] == "sha256": # Simulate pkg(5) where SHA-1 is no longer used for publication DEFAULT_HASH_ATTRS = ["pkg.hash.sha256"] @@ -148,9 +127,6 @@ else: "pkg.hash.sha256": hashlib.sha256, } - if sha512_supported: - HASH_ALGS["pkg.hash.sha512_256"] = pkg.sha512_t.SHA512_t - # A dictionary of the compressed hash attributes we know about. CHASH_ALGS = {} for key in HASH_ALGS: @@ -191,21 +167,13 @@ for key in HASH_ALGS: if DebugValues["hash"] == "sha1": RANKED_HASH_ATTRS = ("hash") elif DebugValues["hash"] == "sha2": - if sha512_supported: - RANKED_HASH_ATTRS = ("pkg.hash.sha512_256",) - else: - RANKED_HASH_ATTRS = ("pkg.hash.sha256",) + RANKED_HASH_ATTRS = ("pkg.hash.sha256",) else: RANKED_HASH_ATTRS = ( "pkg.hash.sha256", "hash", ) - if sha512_supported: - RANKED_HASH_ATTRS = ( - "pkg.hash.sha512_256", - ) + RANKED_HASH_ATTRS - RANKED_CHASH_ATTRS = tuple(key.replace("hash", "chash") for key in RANKED_HASH_ATTRS) _content_hash_attrs = [] diff --git a/src/modules/sha512_t.c b/src/modules/sha512_t.c deleted file mode 100644 index 5ae4a3ed..00000000 --- a/src/modules/sha512_t.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - */ - -#include -#include -#include "structmember.h" - -/* - * A hash module computes SHA512/t. Now it only supports SHA512/256 and - * SHA512/224. - * - * The default hash function is SHA512/256. Change your hash function to - * SHA512/224 with the argument t=224 when you create a hash object. - * - * Hash objects have methods update(arg), digest() and hexdigest(), and an - * attribute hash_size. - * - * For example: - * - * >>> import pkg.sha512_t - * >>> a = pkg.sha512_t.SHA512_t() - * >>> a.update("abc") - * >>> a.digest() - * 'S\x04\x8e&\x81\x94\x1e\xf9\x9b.)\xb7kL}\xab\xe4\xc2\xd0\xc64\xfcmF\xe0\xe2 - * \xf11\x07\xe7\xaf#' - * More condensed: - * - * >>> pkg.sha512_t.SHA512_t("abc").hexdigest() - * '53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23' - * - * >>> pkg.sha512_t.SHA512_t(t=224).hexdigest() - * '4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa' - * - */ - -typedef struct { - PyObject_HEAD - SHA512_CTX shc; - int hash_size; -} SHA512_t_Object; - -static void -py_dealloc(SHA512_t_Object* self) -{ - self->ob_type->tp_free((PyObject*)self); -} - -/* - * Create an SHA512_t object, with optional arguments: string message and - * hash size. - * - */ - -/*ARGSUSED*/ -static int -py_init(SHA512_t_Object *self, PyObject *args, PyObject *kwds) -{ - PyObject *strObj = NULL; - char *message; - /* Default hash algorithm is SHA512/256. */ - self->hash_size = 256; - static char *kwlist[] = {"message", "t", NULL}; - - if (PyArg_ParseTupleAndKeywords(args, kwds, "|Si", kwlist, - &strObj, &self->hash_size) == 0) - return (-1); - - if (self->hash_size != 256 && self->hash_size != 224) { - PyErr_SetString(PyExc_ValueError, "The module " - "only supports SHA512/256 or SHA512/224.\n"); - return (-1); - } - - SHA512_t_Init(self->hash_size, &self->shc); - if (strObj != NULL) { - if ((message = PyBytes_AsString(strObj)) == NULL) - return (-1); - SHA512_t_Update(&self->shc, message, strlen(message)); - } - return (0); -} - -/* - * Update the hash object with a string object. Repeated calls are equivalent - * to a single call with the concatenation of all the strings. - * - */ - -static char py_update_doc[] = "\n\ -Update the hash object with the string arguments.\n\ -\n\ -@param message: input message to digest\n\ -\n\ -@return: None\n\ -"; - -/*ARGSUSED*/ -static PyObject * -py_update(SHA512_t_Object* self, PyObject *args) -{ - PyObject *strObj = NULL; - char *message; - - if (!PyArg_ParseTuple(args, "S", &strObj)) - return (NULL); - - if (strObj != NULL) { - if ((message = PyBytes_AsString(strObj)) == NULL) - return (NULL); - SHA512_t_Update(&self->shc, message, strlen(message)); - } - Py_RETURN_NONE; -} - -/* - * Return the digest of the strings passed to the py_update() method so far. - * - */ - -static char py_digest_doc[] = "\n\ -Return the digest of the strings passed to the update() method so far.\n\ -\n\ -@return: string of digest of messages\n\ -"; - -/*ARGSUSED*/ -static PyObject * -py_digest(SHA512_t_Object* self, PyObject *args) -{ - int size = self->hash_size / 8; - unsigned char buffer[size]; - SHA512_CTX shc; - shc = self->shc; - SHA512_t_Final(buffer, &shc); - return (PyString_FromStringAndSize((const char *)buffer, size)); -} - -/* - * Return a string with a hex representation of the digest of the strings - * passed to the py_update() method so far. - * - */ - -static char py_hexdigest_doc[] = "\n\ -Return hexadecimal digest of the strings passed to the update() method\ -so far.\n\ -\n\ -@return: string of double length and hexadecimal digest of the messages\n\ -"; - -/*ARGSUSED*/ -static PyObject * -py_hexdigest(SHA512_t_Object* self, PyObject *args) -{ - int i; - int buffer_size = self->hash_size / 8; - int result_size = self->hash_size / 4; - unsigned char buffer[buffer_size]; - unsigned char result[result_size]; - char hexchars[16] = "0123456789abcdef"; - SHA512_CTX shc; - shc = self->shc; - SHA512_t_Final(buffer, &shc); - for (i = 0; i < buffer_size; i++) { - result[2 * i] = \ - hexchars[(buffer[i] & 0xf0) >> 4]; - result[2 * i + 1] = \ - hexchars[buffer[i] & 0x0f]; - } - return (PyString_FromStringAndSize((const char *)result, result_size)); -} - -static PyMemberDef SHA512_t_members[] = { - { "hash_size", T_INT, offsetof(SHA512_t_Object, hash_size), 0, - "hash size"}, - { NULL } /* Sentinel */ -}; - -static PyMethodDef SHA512_t_methods[] = { - { "update", (PyCFunction)py_update, METH_VARARGS, - py_update_doc }, - { "digest", (PyCFunction)py_digest, METH_NOARGS, - py_digest_doc }, - { "hexdigest", (PyCFunction)py_hexdigest, METH_NOARGS, - py_hexdigest_doc }, - { NULL } /* Sentinel */ -}; - -static PyTypeObject SHA512_t_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "sha512_t.SHA512_t", /* tp_name */ - sizeof (SHA512_t_Object), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)py_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "SHA512/t objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - SHA512_t_methods, /* tp_methods */ - SHA512_t_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)py_init, /* tp_init */ -}; - -static PyMethodDef sha512_t_methods[] = { - { NULL } /* Sentinel */ -}; - -PyMODINIT_FUNC -initsha512_t(void) -{ - PyObject* m; - - SHA512_t_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&SHA512_t_Type) < 0) - return; - - m = Py_InitModule3("sha512_t", sha512_t_methods, - "This module provides SHA512_t hashing."); - - if (m == NULL) - return; - - Py_INCREF(&SHA512_t_Type); - PyModule_AddObject(m, "SHA512_t", (PyObject *)&SHA512_t_Type); -} diff --git a/src/pkg/manifests/package:pkg.p5m b/src/pkg/manifests/package:pkg.p5m index 048a986a..b29b7db6 100644 --- a/src/pkg/manifests/package:pkg.p5m +++ b/src/pkg/manifests/package:pkg.p5m @@ -40,7 +40,6 @@ file path=$(PYDIRVP)/pkg/64/_varcet.so file path=$(PYDIRVP)/pkg/64/arch.so file path=$(PYDIRVP)/pkg/64/elf.so file path=$(PYDIRVP)/pkg/64/pspawn.so -file path=$(PYDIRVP)/pkg/64/sha512_t.so file path=$(PYDIRVP)/pkg/64/solver.so file path=$(PYDIRVP)/pkg/64/sysattr.so file path=$(PYDIRVP)/pkg/64/syscallat.so @@ -204,7 +203,6 @@ file path=$(PYDIRVP)/pkg/server/feed.py file path=$(PYDIRVP)/pkg/server/query_parser.py file path=$(PYDIRVP)/pkg/server/repository.py file path=$(PYDIRVP)/pkg/server/transaction.py -file path=$(PYDIRVP)/pkg/sha512_t.so file path=$(PYDIRVP)/pkg/smf.py file path=$(PYDIRVP)/pkg/solver.so file path=$(PYDIRVP)/pkg/sysattr.so diff --git a/src/setup.py b/src/setup.py index 5dd6a157..85190677 100755 --- a/src/setup.py +++ b/src/setup.py @@ -398,9 +398,6 @@ userattrd_files = ['util/misc/user_attr.d/package:pkg'] pkg_locales = \ 'ar ca cs de es fr he hu id it ja ko nl pl pt_BR ru sk sv zh_CN zh_HK zh_TW'.split() -sha512_t_srcs = [ - 'modules/sha512_t.c' - ] sysattr_srcs = [ 'modules/sysattr.c' ] @@ -591,12 +588,6 @@ class clint_func(Command): ['-I' + self.escape(get_python_inc())] + \ ["{0}{1}".format("-l", k) for k in sysattr_libraries] + \ sysattr_srcs - sha512_tcmd = lint + lint_flags + \ - ['-D_FILE_OFFSET_BITS=64'] + \ - ["{0}{1}".format("-I", k) for k in include_dirs] + \ - ['-I' + self.escape(get_python_inc())] + \ - ["{0}{1}".format("-l", k) for k in sha512_t_libraries] + \ - sha512_t_srcs print(" ".join(archcmd)) os.system(" ".join(archcmd)) @@ -614,8 +605,6 @@ class clint_func(Command): os.system(" ".join(syscallatcmd)) print(" ".join(sysattrcmd)) os.system(" ".join(sysattrcmd)) - print(" ".join(sha512_tcmd)) - os.system(" ".join(sha512_tcmd)) # Runs both C and Python lint @@ -1510,7 +1499,6 @@ ext_modules = [ ] elf_libraries = None sysattr_libraries = None -sha512_t_libraries = None data_files = web_files cmdclasses = { 'install': install_func, @@ -1591,7 +1579,6 @@ if osname in ['sunos', 'unleashed', 'linux']: if osname == 'sunos' or osname == 'unleashed': elf_libraries += [ 'md' ] sysattr_libraries = [ 'nvpair' ] - sha512_t_libraries = [ 'md' ] ext_modules += [ Extension( 'arch', @@ -1630,16 +1617,6 @@ if osname in ['sunos', 'unleashed', 'linux']: define_macros = [('_FILE_OFFSET_BITS', '64')], build_64 = True ), - Extension( - 'sha512_t', - sha512_t_srcs, - include_dirs = include_dirs, - libraries = sha512_t_libraries, - extra_compile_args = compile_args, - extra_link_args = link_args, - define_macros = [('_FILE_OFFSET_BITS', '64')], - build_64 = True - ), ] else: elf_libraries += [ 'ssl' ] diff --git a/src/tests/api/t_sha512_t.py b/src/tests/api/t_sha512_t.py deleted file mode 100644 index d9855c2e..00000000 --- a/src/tests/api/t_sha512_t.py +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/python2.7 -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. -# - -import testutils -if __name__ == "__main__": - testutils.setup_environment("../../../proto") -import pkg5unittest - -import unittest - -try: - import pkg.sha512_t as sha512_t - sha512_supported = True -except ImportError: - sha512_supported = False - -class TestPkgSha(pkg5unittest.Pkg5TestCase): - """A class tests the sha512_t module.""" - - def test_basic(self): - if not sha512_supported: - return - - # The expected values are from the examples: - # http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA512_224.pdf - # http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA512_256.pdf - - # Test SHA512/256 - # Test hexdigest() - a = sha512_t.SHA512_t() - a.update("abc") - expected = "53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23" - output = a.hexdigest() - self.assertEqualDiff(expected, output) - - a = sha512_t.SHA512_t("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu") - expected = "3928e184fb8690f840da3988121d31be65cb9d3ef83ee6146feac861e19b563a" - output = a.hexdigest() - self.assertEqualDiff(expected, output) - - # Test the length of the output of hexdigest() - output = len(sha512_t.SHA512_t("0.861687995815").hexdigest()) - self.assertEqualDiff(64, output) - output = len(sha512_t.SHA512_t("0.861687995815", 224).hexdigest()) - self.assertEqualDiff(56, output) - - # Test digest() - a = sha512_t.SHA512_t() - a.update("abc") - expected = "S\x04\x8e&\x81\x94\x1e\xf9\x9b.)\xb7kL}\xab\xe4\xc2\xd0\xc64\xfcmF\xe0\xe2\xf11\x07\xe7\xaf#" - output = a.digest() - self.assertEqualDiff(expected, output) - - # Test the length of the output of digest() - output = len(sha512_t.SHA512_t("0.861687995815").digest()) - self.assertEqualDiff(32, output) - output = len(sha512_t.SHA512_t("0.861687995815", 224).digest()) - self.assertEqualDiff(28, output) - - # Test update() - a = sha512_t.SHA512_t("a") - a.update("bc") - expected = "53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23" - output = a.hexdigest() - self.assertEqualDiff(expected, output) - - a = sha512_t.SHA512_t("a") - a.digest() - a.update("b") - a.hexdigest() - a.update("c") - output = a.hexdigest() - self.assertEqualDiff(expected, output) - - # Test hash_size - a = sha512_t.SHA512_t() - self.assertEqualDiff("256", a.hash_size) - - # Test SHA512/224 - a = sha512_t.SHA512_t(t=224) - a.update("abc") - expected = "4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa" - output = a.hexdigest() - self.assertEqualDiff(expected, output) - - a = sha512_t.SHA512_t("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", t=224) - expected = "23fec5bb94d60b23308192640b0c453335d664734fe40e7268674af9" - output = a.hexdigest() - self.assertEqualDiff(expected, output) - - # Test positional arguments - a = sha512_t.SHA512_t("abc", 224) - expected = "4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa" - output = a.hexdigest() - self.assertEqualDiff(expected, output) - - # Test keyword arguments - a = sha512_t.SHA512_t(message="abc", t=224) - expected = "4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa" - output = a.hexdigest() - self.assertEqualDiff(expected, output) - - # Test scalability - a = sha512_t.SHA512_t() - for i in xrange(1000000): - a.update("abc") - a.hexdigest() - - # Test bad input - self.assertRaises(TypeError, sha512_t.SHA512_t, 8) - self.assertRaises(ValueError, sha512_t.SHA512_t, t=160) - self.assertRaises(TypeError, sha512_t.SHA512_t.update, 8) - - -if __name__ == "__main__": - unittest.main() diff --git a/src/tests/cli/t_pkg_install.py b/src/tests/cli/t_pkg_install.py index 70e6f999..1633330d 100644 --- a/src/tests/cli/t_pkg_install.py +++ b/src/tests/cli/t_pkg_install.py @@ -52,12 +52,6 @@ import pkg.portable as portable from pkg.client.pkgdefs import EXIT_OOPS -try: - import pkg.sha512 - sha512_supported = True -except ImportError: - sha512_supported = False - class _TestHelper(object): """Private helper class for shared functionality between test classes.""" @@ -3978,9 +3972,6 @@ adm self.many_hashalgs_helper("install", "sha256") self.many_hashalgs_helper("exact-install", "sha256") - if sha512_supported: - self.many_hashalgs_helper("install", "sha512_256") - self.many_hashalgs_helper("exact-install", "sha512_256") def many_hashalgs_helper(self, install_cmd, hash_alg): self.pkgsend_bulk(self.rurl, (self.iron10)) diff --git a/src/tests/cli/t_pkg_revert.py b/src/tests/cli/t_pkg_revert.py index 7ae543b8..f925d868 100644 --- a/src/tests/cli/t_pkg_revert.py +++ b/src/tests/cli/t_pkg_revert.py @@ -34,12 +34,6 @@ import pkg.portable as portable import pkg.misc as misc import sys -try: - import pkg.sha512 - sha512_supported = True -except ImportError: - sha512_supported = False - class TestPkgRevert(pkg5unittest.SingleDepotTestCase): # Only start/stop the depot once (instead of for every test) persistent_setup = True @@ -143,12 +137,8 @@ class TestPkgRevert(pkg5unittest.SingleDepotTestCase): self.plist = self.pkgsend_bulk(self.rurl, self.pkgs) self.plist.extend(self.pkgsend_bulk(self.rurl, self.pkgs2, debug_hash="sha1+sha256")) - if sha512_supported: - self.plist.extend(self.pkgsend_bulk(self.rurl, - self.pkgs3, debug_hash="sha1+sha512_256")) - else: - self.plist.extend(self.pkgsend_bulk(self.rurl, - self.pkgs3)) + self.plist.extend(self.pkgsend_bulk(self.rurl, + self.pkgs3)) def test_revert(self): self.image_create(self.rurl) @@ -170,10 +160,6 @@ class TestPkgRevert(pkg5unittest.SingleDepotTestCase): self.pkg("verify B", exit=1) self.assert_(sha2 in self.output) - if sha512_supported: - self.pkg("-D hash=sha1+sha512_256 verify C", exit=1) - sha2 = "13729cb7183961b48ce300c2588c86ad123e7c636f38a0f3c8408a75fd079d09" - self.assert_(sha2 in self.output, self.output) self.pkg("verify C", exit=1) self.pkg("verify D", exit=1) @@ -215,13 +201,6 @@ class TestPkgRevert(pkg5unittest.SingleDepotTestCase): # our repository stores its files by the SHA1 hash. self.pkg("-D hash=sha256 revert --parsable=0 --tagged bob", exit=1) - if sha512_supported: - self.pkg("-D hash=sha512_256 revert --parsable=0 \ - --tagged ted", exit=1) - self.pkg("-D hash=sha1+512_256 revert -n --parsable=0 \ - --tagged ted") - self.assertEqualParsable(self.output, - affect_packages=[self.plist[12], self.plist[1]]) self.pkg("-D hash=sha1+sha256 revert --parsable=0 --tagged bob") self.assertEqualParsable(self.output, affect_packages=[self.plist[9], self.plist[12], diff --git a/src/tests/cli/t_pkg_search.py b/src/tests/cli/t_pkg_search.py index a250c8eb..dc7d6de9 100644 --- a/src/tests/cli/t_pkg_search.py +++ b/src/tests/cli/t_pkg_search.py @@ -44,12 +44,6 @@ import pkg.fmri as fmri import pkg.indexer as indexer import pkg.portable as portable -try: - import pkg.sha512_t as sha512_t - sha512_supported = True -except ImportError: - sha512_supported = False - class TestPkgSearchBasics(pkg5unittest.SingleDepotTestCase): example_pkg10 = """ @@ -1131,18 +1125,6 @@ class TestSearchMultiPublisher(pkg5unittest.ManyDepotTestCase): actions at publication time.""" self.base_search_multi_hash("sha256", hashlib.sha256) - def test_search_multi_hash_2(self): - """Check that when searching a repository with multiple - hashes, all hash attributes are indexed and we can search - against all hash attributes. - - This test depends on pkg.digest having DebugValue settings - that add sha512/256 hashes to the set of hashes we append to - actions at publication time.""" - if sha512_supported: - self.base_search_multi_hash("sha512_256", - sha512_t.SHA512_t) - def base_search_multi_hash(self, hash_alg, hash_fun): # our 2nd depot gets the package published with multiple hash # attributes, but served from a single-hash-aware depot diff --git a/src/tests/cli/t_pkg_sysrepo.py b/src/tests/cli/t_pkg_sysrepo.py index 846c1be1..dcbb7278 100644 --- a/src/tests/cli/t_pkg_sysrepo.py +++ b/src/tests/cli/t_pkg_sysrepo.py @@ -39,12 +39,6 @@ import pkg.client.transport.exception as tx import pkg.digest as digest import pkg.misc as misc -try: - import pkg.sha512_t - sha512_supported = True -except ImportError: - sha512_supported = False - class PC(object): """This class contains publisher configuration used for setting up the depots and https apache instances needed by the tests.""" @@ -172,9 +166,6 @@ test4\ttrue\ttrue\ttrue\t\t\t\t debug_hash="sha1+sha256") self.pkgsend_bulk(self.rurl3, self.baz10, debug_hash="sha1+sha256") - if sha512_supported: - self.pkgsend_bulk(self.rurl3, self.caz10, - debug_hash="sha1+sha512_256") self.pkgsend_bulk(self.rurl4, self.bar10) self.pkgsend_bulk(self.rurl5, self.foo11) @@ -629,10 +620,6 @@ test4\ttrue\ttrue\ttrue\t\t\t\t self.pkg("install baz") self.pkg("contents -m baz") self.assert_("pkg.hash.sha256" in self.output) - if sha512_supported: - self.pkg("install caz") - self.pkg("contents -m caz") - self.assert_("pkg.hash.sha512_256" in self.output) def test_02_communication(self): """Test that the transport for communicating with the depots is @@ -965,15 +952,7 @@ test3\ttrue\ttrue\ttrue\torigin\tonline\t{durl3}/\thttp://localhost:{port} # both the old configuration and the current configuration. self.__check_publisher_dirs(["test1"]) - if sha512_supported: - expected = """\ -bar (test3) 1.0-0 --- -baz (test3) 1.0-0 --- -caz (test3) 1.0-0 --- -example_pkg 1.0-0 --- -""" - else: - expected = """\ + expected = """\ bar (test3) 1.0-0 --- baz (test3) 1.0-0 --- example_pkg 1.0-0 --- @@ -1000,15 +979,7 @@ test3\ttrue\ttrue\ttrue\torigin\tonline\t{durl3}/\thttp://localhost:{port} self.__check_publisher_info(expected) self.__check_publisher_dirs(["test1", "test3"]) - if sha512_supported: - expected = """\ -bar (test3) 1.0-0 --- -baz (test3) 1.0-0 --- -caz (test3) 1.0-0 --- -example_pkg 1.0-0 --- -""" - else: - expected = """\ + expected = """\ bar (test3) 1.0-0 --- baz (test3) 1.0-0 --- example_pkg 1.0-0 --- diff --git a/src/tests/cli/t_pkgrecv.py b/src/tests/cli/t_pkgrecv.py index 7337cf49..4c2b0ca9 100644 --- a/src/tests/cli/t_pkgrecv.py +++ b/src/tests/cli/t_pkgrecv.py @@ -50,12 +50,6 @@ import zlib from pkg.digest import DEFAULT_HASH_FUNC -try: - import pkg.sha512_t - sha512_supported = True -except ImportError: - sha512_supported = False - class TestPkgrecvMulti(pkg5unittest.ManyDepotTestCase): # Cleanup after every test. persistent_setup = False @@ -935,8 +929,6 @@ class TestPkgrecvMulti(pkg5unittest.ManyDepotTestCase): multi-hash support, interoperating with repositories without multi-hash support.""" self.base_12_multihash("sha256") - if sha512_supported: - self.base_12_multihash("sha512_256") def base_12_multihash(self, hash_alg): f = fmri.PkgFmri(self.published[3], None) diff --git a/src/tests/cli/t_pkgrepo.py b/src/tests/cli/t_pkgrepo.py index 9ebdf0dc..30ec095f 100644 --- a/src/tests/cli/t_pkgrepo.py +++ b/src/tests/cli/t_pkgrepo.py @@ -48,12 +48,6 @@ import urllib import urlparse import unittest -try: - import pkg.sha512_t - sha512_supported = True -except ImportError: - sha512_supported = False - class TestPkgRepo(pkg5unittest.SingleDepotTestCase): # Cleanup after every test. persistent_setup = False @@ -1543,8 +1537,6 @@ publisher\tprefix\texample.net self.assert_(not os.listdir(rstore.file_root)) hash_alg_list = ["sha256"] - if sha512_supported: - hash_alg_list.append("sha512_256") for hash_alg in hash_alg_list: # Reset the src_repo for the rest of the test. shutil.rmtree(src_repo) @@ -2126,8 +2118,6 @@ test2 zoo 1.0 5.11 0 20110804T203458Z pkg://test2/zoo@1.0,5.11-0:20110804T20345 # Check that when verifying content, we always use the most # preferred hash. hash_alg_list = ["sha256"] - if sha512_supported: - hash_alg_list.append("sha512_256") for hash_alg in hash_alg_list: # Remove all existing packages first. self.pkgrepo("-s {0} remove {1}".format(repo_path, diff --git a/src/tests/cli/t_pkgsend.py b/src/tests/cli/t_pkgsend.py index a6cd7b57..e2494a37 100644 --- a/src/tests/cli/t_pkgsend.py +++ b/src/tests/cli/t_pkgsend.py @@ -44,13 +44,6 @@ from pkg.actions import fromstr from pkg.digest import DEFAULT_HASH_FUNC import pkg.portable as portable -try: - import pkg.sha512_t - sha512_supported = True -except ImportError: - sha512_supported = False - - class TestPkgsendBasics(pkg5unittest.SingleDepotTestCase): persistent_setup = False @@ -1304,8 +1297,6 @@ dir path=/usr/bin/foo target=bar hash=payload-pathname""") compute, other attributes are left alone.""" self.base_26_pkgsend_multihash("sha256") - if sha512_supported: - self.base_26_pkgsend_multihash("sha512_256") def base_26_pkgsend_multihash(self, hash_alg): # we use a file:// URI rather than the repo URI so we don't have diff --git a/src/tests/cli/t_pkgsign.py b/src/tests/cli/t_pkgsign.py index 70e22fee..e8a36a2e 100644 --- a/src/tests/cli/t_pkgsign.py +++ b/src/tests/cli/t_pkgsign.py @@ -49,12 +49,6 @@ import M2Crypto as m2 from pkg.client.debugvalues import DebugValues from pkg.pkggzip import PkgGzipFile -try: - import pkg.sha512_t - sha512_supported = True -except ImportError: - sha512_supported = False - obsolete_pkg = """ open obs@1.0,5.11-0 add set name=pkg.obsolete value=true @@ -533,8 +527,6 @@ class TestPkgSign(pkg5unittest.SingleDepotTestCase): signature doesn't cause anything to break.""" self.base_multiple_signatures("sha256") - if sha512_supported: - self.base_multiple_signatures("sha512_256") def test_no_empty_chain(self): """Test that signing do not create empty chain""" @@ -2370,8 +2362,6 @@ class TestPkgSign(pkg5unittest.SingleDepotTestCase): fh.write(l) hash_alg_list = ["sha256"] - if sha512_supported: - hash_alg_list.append("sha512_256") for hash_alg in hash_alg_list: # Rebuild the catalog so that hash verification for the # manifest won't cause problems. -- 2.11.4.GIT