Run of fresh-snapshots for golang-github-thalesignite-crypto11

Merge these changes:

Summary

Merged new upstream version: 1.2.5 (was: 1.2.4).

Diff

diff --git a/crypto11.go b/crypto11.go
index 5dd2b58..f68fd93 100644
--- a/crypto11.go
+++ b/crypto11.go
@@ -109,6 +109,10 @@ const (
 
 	// DefaultGCMIVLength controls the expected length of IVs generated by the token
 	DefaultGCMIVLength = 16
+
+	// Thales vendor constant for CKU_CRYPTO_USER
+	CryptoUser      = 0x80000001
+	DefaultUserType = 1 // 1 -> CKU_USER
 )
 
 // errTokenNotFound represents the failure to find the requested PKCS#11 token
@@ -241,6 +245,9 @@ type Config struct {
 	// Otherwise, the value specified must be at least 2.
 	MaxSessions int
 
+	// User type identifies the user type logging in. If zero, DefaultUserType is used.
+	UserType int
+
 	// Maximum time to wait for a session from the sessions pool. Zero means wait indefinitely.
 	PoolWaitTimeout time.Duration
 
@@ -300,6 +307,10 @@ func Configure(config *Config) (*Context, error) {
 		return nil, errors.New("MaxSessions must be larger than 1")
 	}
 
+	if config.UserType == 0 {
+		config.UserType = DefaultUserType
+	}
+
 	if config.GCMIVLength == 0 {
 		config.GCMIVLength = DefaultGCMIVLength
 	}
@@ -361,7 +372,11 @@ func Configure(config *Config) (*Context, error) {
 	if !config.LoginNotSupported {
 		// Try to log in our persistent session. This may fail with CKR_USER_ALREADY_LOGGED_IN if another instance
 		// already exists.
-		err = instance.ctx.Login(instance.persistentSession, pkcs11.CKU_USER, instance.cfg.Pin)
+		if instance.cfg.UserType == 1 {
+			err = instance.ctx.Login(instance.persistentSession, pkcs11.CKU_USER, instance.cfg.Pin)
+		} else {
+			err = instance.ctx.Login(instance.persistentSession, CryptoUser, instance.cfg.Pin)
+		}
 		if err != nil {
 
 			pErr, isP11Error := err.(pkcs11.Error)
diff --git a/debian/changelog b/debian/changelog
index 94e63a9..7a4d025 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-thalesignite-crypto11 (1.2.5-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Sat, 26 Feb 2022 19:06:05 -0000
+
 golang-github-thalesignite-crypto11 (1.2.4-2) unstable; urgency=medium
 
   * Testing migration
diff --git a/dsa_test.go b/dsa_test.go
index ab0d73e..a6b0aad 100644
--- a/dsa_test.go
+++ b/dsa_test.go
@@ -163,9 +163,12 @@ func testDsaSigningWithHash(t *testing.T, key crypto.Signer, hashFunction crypto
 	require.NoError(t, err)
 
 	plaintextHash := h.Sum([]byte{}) // weird API
-	// crypto.dsa.Sign doesn't truncate the hash!
-	qbytes := (dsaSizes[psize].Q.BitLen() + 7) / 8
-	plaintextHash = plaintextHash[:qbytes]
+	// According to FIPS 186-3, section 4.6, the hash should be truncated to the byte-length of the subgroup
+	// if it is longer than the subgroup length, but crypto/dsa doesn't do it automatically.
+	subgroupSize := (dsaSizes[psize].Q.BitLen() + 7) / 8
+	if len(plaintextHash) > subgroupSize {
+		plaintextHash = plaintextHash[:subgroupSize]
+	}
 
 	sigDER, err := key.Sign(rand.Reader, plaintextHash, hashFunction)
 	require.NoError(t, err)

Publish Blockers

  • ☑ run was successful
  • ☑ package has not been removed from the archive
  • ☑ command has not changed
  • ☒ not yet reviewed, but review needed
  • ☑ 0 publish attempts so far.not currently attempting to back off
  • ☒ merge proposals for the package maintainer are currently being rate-limited (open: 1258, max open: 200)
  • ☑ change set 176140e3-bfb6-4ca3-ac37-4f7df8c337e2 is ready

Resulting package

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots golang-github-thalesignite-crypto11-dev

Lintian Result

Full worker log Full build log