libgo: update to Go 1.6.1 release
Reviewed-on: https://go-review.googlesource.com/22007 From-SVN: r234958
This commit is contained in:
parent
10c3c4245b
commit
88b5d499b5
@ -1,4 +1,4 @@
|
|||||||
8e7b5e777333fa4cd070d96e94ea82e3e1132739
|
ff29ea8e4e69eb94958aef4388da09a61b2b52b6
|
||||||
|
|
||||||
The first line of this file holds the git revision number of the last
|
The first line of this file holds the git revision number of the last
|
||||||
merge done from the gofrontend repository.
|
merge done from the gofrontend repository.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
7bc40ffb05d8813bf9b41a331b45d37216f9e747
|
f5cf5673590a68c55b2330df9dfcdd6fac75b893
|
||||||
|
|
||||||
The first line of this file holds the git revision number of the
|
The first line of this file holds the git revision number of the
|
||||||
last merge done from the master library sources.
|
last merge done from the master library sources.
|
||||||
|
@ -1 +1 @@
|
|||||||
go1.6
|
go1.6.1
|
@ -249,6 +249,10 @@ func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err err
|
|||||||
func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool {
|
func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool {
|
||||||
// FIPS 186-3, section 4.7
|
// FIPS 186-3, section 4.7
|
||||||
|
|
||||||
|
if pub.P.Sign() == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if r.Sign() < 1 || r.Cmp(pub.Q) >= 0 {
|
if r.Sign() < 1 || r.Cmp(pub.Q) >= 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
)
|
)
|
||||||
@ -140,6 +141,8 @@ func fermatInverse(k, N *big.Int) *big.Int {
|
|||||||
return new(big.Int).Exp(k, nMinus2, N)
|
return new(big.Int).Exp(k, nMinus2, N)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errZeroParam = errors.New("zero parameter")
|
||||||
|
|
||||||
// Sign signs an arbitrary length hash (which should be the result of hashing a
|
// Sign signs an arbitrary length hash (which should be the result of hashing a
|
||||||
// larger message) using the private key, priv. It returns the signature as a
|
// larger message) using the private key, priv. It returns the signature as a
|
||||||
// pair of integers. The security of the private key depends on the entropy of
|
// pair of integers. The security of the private key depends on the entropy of
|
||||||
@ -180,7 +183,9 @@ func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err err
|
|||||||
// See [NSA] 3.4.1
|
// See [NSA] 3.4.1
|
||||||
c := priv.PublicKey.Curve
|
c := priv.PublicKey.Curve
|
||||||
N := c.Params().N
|
N := c.Params().N
|
||||||
|
if N.Sign() == 0 {
|
||||||
|
return nil, nil, errZeroParam
|
||||||
|
}
|
||||||
var k, kInv *big.Int
|
var k, kInv *big.Int
|
||||||
for {
|
for {
|
||||||
for {
|
for {
|
||||||
@ -193,7 +198,7 @@ func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err err
|
|||||||
if in, ok := priv.Curve.(invertible); ok {
|
if in, ok := priv.Curve.(invertible); ok {
|
||||||
kInv = in.Inverse(k)
|
kInv = in.Inverse(k)
|
||||||
} else {
|
} else {
|
||||||
kInv = fermatInverse(k, N)
|
kInv = fermatInverse(k, N) // N != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
r, _ = priv.Curve.ScalarBaseMult(k.Bytes())
|
r, _ = priv.Curve.ScalarBaseMult(k.Bytes())
|
||||||
@ -207,7 +212,7 @@ func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err err
|
|||||||
s = new(big.Int).Mul(priv.D, r)
|
s = new(big.Int).Mul(priv.D, r)
|
||||||
s.Add(s, e)
|
s.Add(s, e)
|
||||||
s.Mul(s, kInv)
|
s.Mul(s, kInv)
|
||||||
s.Mod(s, N)
|
s.Mod(s, N) // N != 0
|
||||||
if s.Sign() != 0 {
|
if s.Sign() != 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -465,6 +465,9 @@ func decrypt(random io.Reader, priv *PrivateKey, c *big.Int) (m *big.Int, err er
|
|||||||
err = ErrDecryption
|
err = ErrDecryption
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if priv.N.Sign() == 0 {
|
||||||
|
return nil, ErrDecryption
|
||||||
|
}
|
||||||
|
|
||||||
var ir *big.Int
|
var ir *big.Int
|
||||||
if random != nil {
|
if random != nil {
|
||||||
@ -490,7 +493,7 @@ func decrypt(random io.Reader, priv *PrivateKey, c *big.Int) (m *big.Int, err er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bigE := big.NewInt(int64(priv.E))
|
bigE := big.NewInt(int64(priv.E))
|
||||||
rpowe := new(big.Int).Exp(r, bigE, priv.N)
|
rpowe := new(big.Int).Exp(r, bigE, priv.N) // N != 0
|
||||||
cCopy := new(big.Int).Set(c)
|
cCopy := new(big.Int).Set(c)
|
||||||
cCopy.Mul(cCopy, rpowe)
|
cCopy.Mul(cCopy, rpowe)
|
||||||
cCopy.Mod(cCopy, priv.N)
|
cCopy.Mod(cCopy, priv.N)
|
||||||
|
@ -132,10 +132,10 @@ var pkgDeps = map[string][]string{
|
|||||||
// End of linear dependency definitions.
|
// End of linear dependency definitions.
|
||||||
|
|
||||||
// Operating system access.
|
// Operating system access.
|
||||||
"syscall": {"L0", "internal/race", "unicode/utf16"},
|
"syscall": {"L0", "internal/race", "internal/syscall/windows/sysdll", "unicode/utf16"},
|
||||||
"internal/syscall/unix": {"L0", "syscall"},
|
"internal/syscall/unix": {"L0", "syscall"},
|
||||||
"internal/syscall/windows": {"L0", "syscall"},
|
"internal/syscall/windows": {"L0", "syscall", "internal/syscall/windows/sysdll"},
|
||||||
"internal/syscall/windows/registry": {"L0", "syscall", "unicode/utf16"},
|
"internal/syscall/windows/registry": {"L0", "syscall", "internal/syscall/windows/sysdll", "unicode/utf16"},
|
||||||
"time": {"L0", "syscall", "internal/syscall/windows/registry"},
|
"time": {"L0", "syscall", "internal/syscall/windows/registry"},
|
||||||
"os": {"L1", "os", "syscall", "time", "internal/syscall/windows"},
|
"os": {"L1", "os", "syscall", "time", "internal/syscall/windows"},
|
||||||
"path/filepath": {"L2", "os", "syscall"},
|
"path/filepath": {"L2", "os", "syscall"},
|
||||||
|
@ -8,7 +8,7 @@ package registry
|
|||||||
|
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
||||||
//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go
|
//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go -systemdll syscall.go
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_REG_OPTION_NON_VOLATILE = 0
|
_REG_OPTION_NON_VOLATILE = 0
|
||||||
|
@ -4,12 +4,13 @@ package registry
|
|||||||
|
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
import "internal/syscall/windows/sysdll"
|
||||||
|
|
||||||
var _ unsafe.Pointer
|
var _ unsafe.Pointer
|
||||||
|
|
||||||
var (
|
var (
|
||||||
modadvapi32 = syscall.NewLazyDLL("advapi32.dll")
|
modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll"))
|
||||||
modkernel32 = syscall.NewLazyDLL("kernel32.dll")
|
modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll"))
|
||||||
|
|
||||||
procRegCreateKeyExW = modadvapi32.NewProc("RegCreateKeyExW")
|
procRegCreateKeyExW = modadvapi32.NewProc("RegCreateKeyExW")
|
||||||
procRegDeleteKeyW = modadvapi32.NewProc("RegDeleteKeyW")
|
procRegDeleteKeyW = modadvapi32.NewProc("RegDeleteKeyW")
|
||||||
|
@ -6,7 +6,7 @@ package windows
|
|||||||
|
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
||||||
//go:generate go run ../../../syscall/mksyscall_windows.go -output zsyscall_windows.go syscall_windows.go
|
//go:generate go run ../../../syscall/mksyscall_windows.go -output zsyscall_windows.go -systemdll syscall_windows.go
|
||||||
|
|
||||||
const GAA_FLAG_INCLUDE_PREFIX = 0x00000010
|
const GAA_FLAG_INCLUDE_PREFIX = 0x00000010
|
||||||
|
|
||||||
|
28
libgo/go/internal/syscall/windows/sysdll/sysdll.go
Normal file
28
libgo/go/internal/syscall/windows/sysdll/sysdll.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright 2016 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 sysdll is an internal leaf package that records and reports
|
||||||
|
// which Windows DLL names are used by Go itself. These DLLs are then
|
||||||
|
// only loaded from the System32 directory. See Issue 14959.
|
||||||
|
package sysdll
|
||||||
|
|
||||||
|
// IsSystemDLL reports whether the named dll key (a base name, like
|
||||||
|
// "foo.dll") is a system DLL which should only be loaded from the
|
||||||
|
// Windows SYSTEM32 directory.
|
||||||
|
//
|
||||||
|
// Filenames are case sensitive, but that doesn't matter because
|
||||||
|
// the case registered with Add is also the same case used with
|
||||||
|
// LoadDLL later.
|
||||||
|
//
|
||||||
|
// It has no associated mutex and should only be mutated serially
|
||||||
|
// (currently: during init), and not concurrent with DLL loading.
|
||||||
|
var IsSystemDLL = map[string]bool{}
|
||||||
|
|
||||||
|
// Add notes that dll is a system32 DLL which should only be loaded
|
||||||
|
// from the Windows SYSTEM32 directory. It returns its argument back,
|
||||||
|
// for ease of use in generated code.
|
||||||
|
func Add(dll string) string {
|
||||||
|
IsSystemDLL[dll] = true
|
||||||
|
return dll
|
||||||
|
}
|
@ -4,12 +4,13 @@ package windows
|
|||||||
|
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
import "internal/syscall/windows/sysdll"
|
||||||
|
|
||||||
var _ unsafe.Pointer
|
var _ unsafe.Pointer
|
||||||
|
|
||||||
var (
|
var (
|
||||||
modiphlpapi = syscall.NewLazyDLL("iphlpapi.dll")
|
modiphlpapi = syscall.NewLazyDLL(sysdll.Add("iphlpapi.dll"))
|
||||||
modkernel32 = syscall.NewLazyDLL("kernel32.dll")
|
modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll"))
|
||||||
|
|
||||||
procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
|
procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
|
||||||
procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
|
procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
|
||||||
|
@ -15,3 +15,7 @@ func NumberOfProcessors() int32 {
|
|||||||
stdcall1(_GetSystemInfo, uintptr(unsafe.Pointer(&info)))
|
stdcall1(_GetSystemInfo, uintptr(unsafe.Pointer(&info)))
|
||||||
return int32(info.dwnumberofprocessors)
|
return int32(info.dwnumberofprocessors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LoadLibraryExStatus() (useEx, haveEx, haveFlags bool) {
|
||||||
|
return useLoadLibraryEx, _LoadLibraryExW != nil, _AddDllDirectory != nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user