// [encoding.BinaryUnmarshaler] to marshal and unmarshal the internal
// state of the hash.
func New() hash.Hash {
- if fips140only.Enabled {
- panic("crypto/md5: use of MD5 is not allowed in FIPS 140-only mode")
- }
d := new(digest)
d.Reset()
return d
func (d *digest) BlockSize() int { return BlockSize }
func (d *digest) Write(p []byte) (nn int, err error) {
+ if fips140only.Enabled {
+ return 0, errors.New("crypto/md5: use of MD5 is not allowed in FIPS 140-only mode")
+ }
// Note that we currently call block or blockGeneric
// directly (guarded using haveAsm) because this allows
// escape analysis to see that p and d don't escape.
}
func (d *digest) checkSum() [Size]byte {
+ if fips140only.Enabled {
+ panic("crypto/md5: use of MD5 is not allowed in FIPS 140-only mode")
+ }
+
// Append 0x80 to the end of the message and then append zeros
// until the length is a multiple of 56 bytes. Finally append
// 8 bytes representing the message length in bits.
// Sum returns the MD5 checksum of the data.
func Sum(data []byte) [Size]byte {
- if fips140only.Enabled {
- panic("crypto/md5: use of MD5 is not allowed in FIPS 140-only mode")
- }
var d digest
d.Reset()
d.Write(data)
if boring.Enabled {
return boring.NewSHA1()
}
- if fips140only.Enabled {
- panic("crypto/sha1: use of weak SHA-1 is not allowed in FIPS 140-only mode")
- }
d := new(digest)
d.Reset()
return d
func (d *digest) BlockSize() int { return BlockSize }
func (d *digest) Write(p []byte) (nn int, err error) {
+ if fips140only.Enabled {
+ return 0, errors.New("crypto/sha1: use of SHA-1 is not allowed in FIPS 140-only mode")
+ }
boring.Unreachable()
nn = len(p)
d.len += uint64(nn)
}
func (d *digest) checkSum() [Size]byte {
+ if fips140only.Enabled {
+ panic("crypto/sha1: use of SHA-1 is not allowed in FIPS 140-only mode")
+ }
+
len := d.len
// Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.
var tmp [64 + 8]byte // padding + length buffer
}
func (d *digest) constSum() [Size]byte {
+ if fips140only.Enabled {
+ panic("crypto/sha1: use of SHA-1 is not allowed in FIPS 140-only mode")
+ }
+
var length [8]byte
l := d.len << 3
for i := uint(0); i < 8; i++ {
return boring.SHA1(data)
}
if fips140only.Enabled {
- panic("crypto/sha1: use of weak SHA-1 is not allowed in FIPS 140-only mode")
+ panic("crypto/sha1: use of SHA-1 is not allowed in FIPS 140-only mode")
}
var d digest
d.Reset()