Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Yes another stupid fix about pubkey along with regression tests this time
Baptiste Daroussin committed 10 years ago
commit c60c40b3c5cf988ace85ac357190ea03bcbee24e
parent 446e6d4960f97e90555e75c8b9508cc5d5efd4bf
4 files changed +53 -1
modified libpkg/rsa.c
@@ -284,7 +284,9 @@ rsa_sign(char *path, struct rsa_key *rsa, unsigned char **sigret, unsigned int *
	if (sha256 == NULL)
		return (EPKG_FATAL);

-
	ret = RSA_sign(NID_sha1, sha256, sizeof(sha256), *sigret, siglen, rsa->key);
+
	ret = RSA_sign(NID_sha1, sha256,
+
	    pkg_checksum_type_size(PKG_HASH_TYPE_SHA256_HEX),
+
	    *sigret, siglen, rsa->key);
	free(sha256);
	if (ret == 0) {
		/* XXX pass back RSA errors correctly */
modified tests/Makefile.am
@@ -87,6 +87,7 @@ tests_scripts= \
		frontend/lock.sh \
		frontend/packagesplit.sh \
		frontend/php-pr.sh \
+
		frontend/pubkey.sh \
		frontend/query.sh \
		frontend/register.sh \
		frontend/repo.sh \
modified tests/frontend/Kyuafile.in
@@ -14,6 +14,7 @@ atf_test_program{name='lock'}
atf_test_program{name='packagesplit'}
atf_test_program{name='php-pr'}
atf_test_program{name='pkg'}
+
atf_test_program{name='pubkey'}
atf_test_program{name='query'}
atf_test_program{name='register'}
atf_test_program{name='repo'}
added tests/frontend/pubkey.sh
@@ -0,0 +1,48 @@
+
#! /usr/bin/env atf-sh
+

+
atf_test_case pubkey
+
pubkey_body() {
+
	atf_check -o ignore -e ignore \
+
		openssl genrsa -out repo.key 2048
+
	chmod 0400 repo.key
+
	atf_check -o ignore -e ignore \
+
		openssl rsa -in repo.key -out repo.pub -pubout
+
	mkdir fakerepo
+

+
	cat >> test.ucl << EOF
+
name: test
+
origin: test
+
version: "1"
+
maintainer: test
+
categories: [test]
+
comment: a test
+
www: http://test
+
prefix: /
+
abi = "*";
+
desc: <<EOD
+
Yet another test
+
EOD
+
EOF
+

+
	atf_check -o ignore -e ignore \
+
		pkg create -M test.ucl -o fakerepo
+
	atf_check -o ignore -e ignore \
+
		pkg repo fakerepo repo.key
+
	cat >> repo.conf << EOF
+
local: {
+
	url: file:///${TMPDIR}/fakerepo
+
	enabled: true
+
	pubkey: ${TMPDIR}/repo.pub
+
	signature_type: "pubkey"
+
}
+
EOF
+
	atf_check \
+
		-o ignore \
+
		pkg -o REPOS_DIR="${TMPDIR}" \
+
		-o ${PKG_CACHEDIR}="${TMPDIR}" update
+
}
+

+
atf_init_test_cases() {
+
	. $(atf_get_srcdir)/test_environment.sh
+
	atf_add_test_case pubkey
+
}