Commit Graph

13 Commits

Author SHA1 Message Date
Miloslav Trmač a56436cb15 Use testing.T.Setenv instead of os.Setenv in tests
... to simplify and benefit from Go 1.17.

In some cases, wrap tests in testing.T.Run() to decrease
the scope, or to make the relationship between the test and the
cleanup clearer.  In some cases it's still a bit awkward
because there is no testing.T.Unsetenv, but still worth it.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-06-14 20:57:04 +02:00
Miloslav Trmač 7152f888b9 Update users of deprecated io/ioutil
Mostly just name changes that should not change behavior,
apart from ioutil.ReadDir -> os.ReadDir avoiding per-item
lstat(2) in some cases.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-04-13 20:46:48 +02:00
Miloslav Trmač 9a9904944d Use testing.T.TempDir()
... to simplify tests.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-03-17 20:35:00 +01:00
Valentin Rothberg 277310915e GPGME: support passphrase for prompt-less signing
To support signing images via gpgme without user prompt, allow for
providing a passphrase via the copy options.  Add a new *WithOptions API
to the `signature` package and extend its interface.

To prevent breaking the API, extend the signature API with an internal
type as has already been done for other types and interfaces.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-25 15:04:52 +01:00
Ivan Voronchihin 4d6079501f Fix this value is never used
Signed-off-by: Ivan Voronchihin <bege13mot@gmail.com>
2019-11-26 18:47:55 +04:00
Miloslav Trmač 978b2bae35 Support v3 signature packets in mechanism_openpgp
They are handled similarly to the more common V4 signature packets,
except that MessageDetails.SignatureV3 is set instead of
MessageDetails.Signature, and they don’t support expiration.

Bulk of the commit is adding tests which use V3 signature packets.

I have regenerated unknown-key.signature because it was generated using
a temporary key created just for that purpose, and the test is simpler
when fixtures for both packet variants to use the same key.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2017-07-29 02:54:07 +02:00
Miloslav Trmač f5768e7cbd Allow choosing between a gpgme and openpgp signature backend using a build tag
The default is gpgme; a containers_image_openpgp build tag can be used
to use openpgp instead.

openpgp does not currently support signing, and is based on mfojtik's
implementation (adding GPG home directory support, parsing of unarmored
keys, and fixing ImportKeysFromBytes semantics).

Also adds build documentation, including the new
containers_image_openpgp build tag, to README.md.

This does not yet hook this into Travis, because that needs a
corresponding skopeo build infrastructure and test update to make it
possible.  That is a separate commit (perhaps a separate PR)?

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2017-03-28 18:57:11 +02:00
Miloslav Trmač d19336da6f Remove SigningMechanism.ImportKeysFromBytes in favor of ephemeral mechanism objects
Instead of SigningMechanism.ImportKeysFromBytes, which may modify
long-term state in the user’s home directory, provide
NewEphemeralGPGSigningMechanism, which combines creation of a temporary
directory and key import; users of NewGPGSigningMechanism (using
$GNUPGHOME etc.) and (test-suite) users of
newGPGSigningMechanismInDirectory can no longer import keys.

To support this, all users of SigningMechanism must call .Close() on the
object.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2017-03-28 18:57:11 +02:00
Miloslav Trmač 596d3190a0 Add signature.GetUntrustedSignatureInformationWithoutVerifying
Add signature.GetUntrustedSignatureInformationWithoutVerifying, which
returns the contents of a signature without doing any cryptographic
verification.

Expected uses are 1) debugging verification failures, and
(CAREFULLY!) 2) listing which signatures are stored in a registry along
with an image.  It is STRONGLY recommended to do cryptographic
verification in the latter case, and to clearly indicate untrusted
signatures in the UI.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2017-01-20 21:11:18 +01:00
Miloslav Trmač e2839c38c5 Add a test for valid signature using an unknown public key
(The key was one-time-generated in a temporary directory,
and is, intentionally, not available.)

This is not conceptually related to the rest of the PR, just adding a
missing case to the test, except that the added fixture will be reused
in a prSignedBy test.
2016-06-02 16:12:10 +02:00
Miloslav Trmač aee0abb5d2 Add SigningMechanism.ImportKeysFromBytes
This will be needed for verification against specified public keys.

Also rerun hack/vendor.sh to pick up import support from
github.com/mtrmac/gpgme .
2016-05-25 16:04:20 +02:00
Antonio Murdaca 7c5db83261 Remove signature/fixtures subpackage
This will make the output of godoc cleaner, we can't filter out the
subpackage otherwise.

Also copy the needed fixture into the integration subpackage, instead of
referring to it using ../signature/fixtures (and we can't import
signature/fixtures_info-test.go now).

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-05-21 21:21:58 +02:00
Miloslav Trmač 69d5a131c9 Add signing and verification to the signature package 2016-03-24 11:32:23 +01:00