diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2019-10-29 16:51:07 +0100 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2019-10-29 16:51:07 +0100 |
| commit | afe18e86a7aa2248c69997ed941bcbe3e6b2a655 (patch) | |
| tree | 7aaef5752ba8ad3465e9638c7adca71e1a103ee3 /vendor/golang.org/x/crypto/pkcs12/mac.go | |
| parent | ef84ca3e82f422118c69a0c562433c185e1dcb9b (diff) | |
| download | gofu-afe18e86a7aa2248c69997ed941bcbe3e6b2a655.tar.gz | |
switch to go.mod
Diffstat (limited to 'vendor/golang.org/x/crypto/pkcs12/mac.go')
| -rw-r--r-- | vendor/golang.org/x/crypto/pkcs12/mac.go | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/vendor/golang.org/x/crypto/pkcs12/mac.go b/vendor/golang.org/x/crypto/pkcs12/mac.go deleted file mode 100644 index 5f38aa7..0000000 --- a/vendor/golang.org/x/crypto/pkcs12/mac.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package pkcs12 - -import ( - "crypto/hmac" - "crypto/sha1" - "crypto/x509/pkix" - "encoding/asn1" -) - -type macData struct { - Mac digestInfo - MacSalt []byte - Iterations int `asn1:"optional,default:1"` -} - -// from PKCS#7: -type digestInfo struct { - Algorithm pkix.AlgorithmIdentifier - Digest []byte -} - -var ( - oidSHA1 = asn1.ObjectIdentifier([]int{1, 3, 14, 3, 2, 26}) -) - -func verifyMac(macData *macData, message, password []byte) error { - if !macData.Mac.Algorithm.Algorithm.Equal(oidSHA1) { - return NotImplementedError("unknown digest algorithm: " + macData.Mac.Algorithm.Algorithm.String()) - } - - key := pbkdf(sha1Sum, 20, 64, macData.MacSalt, password, macData.Iterations, 3, 20) - - mac := hmac.New(sha1.New, key) - mac.Write(message) - expectedMAC := mac.Sum(nil) - - if !hmac.Equal(macData.Mac.Digest, expectedMAC) { - return ErrIncorrectPassword - } - return nil -} |
