Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 150 for bitLen (0.12 sec)

  1. src/crypto/rand/util.go

    	}
    	n = new(big.Int)
    	n.Sub(max, n.SetUint64(1))
    	// bitLen is the maximum bit length needed to encode a value < max.
    	bitLen := n.BitLen()
    	if bitLen == 0 {
    		// the only valid result is 0
    		return
    	}
    	// k is the maximum byte length needed to encode a value < max.
    	k := (bitLen + 7) / 8
    	// b is the number of bits in the most significant byte of max-1.
    	b := uint(bitLen % 8)
    	if b == 0 {
    		b = 8
    	}
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Oct 13 17:09:47 UTC 2023
    - 2.4K bytes
    - Viewed (0)
  2. src/crypto/dsa/dsa_test.go

    	if err != nil {
    		t.Errorf("%d: %s", int(sizes), err)
    		return
    	}
    
    	if params.P.BitLen() != L {
    		t.Errorf("%d: params.BitLen got:%d want:%d", int(sizes), params.P.BitLen(), L)
    	}
    
    	if params.Q.BitLen() != N {
    		t.Errorf("%d: q.BitLen got:%d want:%d", int(sizes), params.Q.BitLen(), L)
    	}
    
    	one := new(big.Int)
    	one.SetInt64(1)
    	pm1 := new(big.Int).Sub(params.P, one)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Nov 15 21:04:43 UTC 2019
    - 4.7K bytes
    - Viewed (0)
  3. test/fibo.go

    			break
    		}
    	}
    	if c != 0 {
    		z[m] = c
    		m++
    	}
    	return z[:m]
    }
    
    func bitlen(x big.Word) int {
    	n := 0
    	for x > 0 {
    		x >>= 1
    		n++
    	}
    	return n
    }
    
    func (x nat) bitlen() int {
    	if i := len(x); i > 0 {
    		return (i-1)*W + bitlen(x[i-1])
    	}
    	return 0
    }
    
    func (x nat) String() string {
    	const shortLen = 10
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Dec 08 22:22:58 UTC 2014
    - 6.3K bytes
    - Viewed (0)
  4. src/crypto/ecdsa/ecdsa_legacy.go

    	// signatures will come out different from other architectures, which will
    	// break TLS recorded tests.
    	for {
    		N := c.Params().N
    		b := make([]byte, (N.BitLen()+7)/8)
    		if _, err = io.ReadFull(rand, b); err != nil {
    			return
    		}
    		if excess := len(b)*8 - N.BitLen(); excess > 0 {
    			b[0] >>= excess
    		}
    		k = new(big.Int).SetBytes(b)
    		if k.Sign() != 0 && k.Cmp(N) < 0 {
    			return
    		}
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 00:11:18 UTC 2024
    - 4.8K bytes
    - Viewed (0)
  5. src/crypto/rand/util_test.go

    // https://golang.org/issue/6849.
    func TestPrimeSmall(t *testing.T) {
    	for n := 2; n < 10; n++ {
    		p, err := rand.Prime(rand.Reader, n)
    		if err != nil {
    			t.Fatalf("Can't generate %d-bit prime: %v", n, err)
    		}
    		if p.BitLen() != n {
    			t.Fatalf("%v is not %d-bit", p, n)
    		}
    		if !p.ProbablyPrime(32) {
    			t.Fatalf("%v is not prime", p)
    		}
    	}
    }
    
    // Test that passing bits < 2 causes Prime to return nil, error
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 05 01:35:39 UTC 2022
    - 3.5K bytes
    - Viewed (0)
  6. src/crypto/x509/boring.go

    		return true
    	}
    
    	// The key must be RSA 2048, RSA 3072, RSA 4096,
    	// or ECDSA P-256, P-384, P-521.
    	switch k := c.PublicKey.(type) {
    	default:
    		return false
    	case *rsa.PublicKey:
    		if size := k.N.BitLen(); size != 2048 && size != 3072 && size != 4096 {
    			return false
    		}
    	case *ecdsa.PublicKey:
    		if k.Curve != elliptic.P256() && k.Curve != elliptic.P384() && k.Curve != elliptic.P521() {
    			return false
    		}
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Jan 26 22:52:27 UTC 2024
    - 993 bytes
    - Viewed (0)
  7. src/crypto/x509/sec1.go

    	if !key.Curve.IsOnCurve(key.X, key.Y) {
    		return nil, errors.New("invalid elliptic key public key")
    	}
    	privateKey := make([]byte, (key.Curve.Params().N.BitLen()+7)/8)
    	return asn1.Marshal(ecPrivateKey{
    		Version:       1,
    		PrivateKey:    key.D.FillBytes(privateKey),
    		NamedCurveOID: oid,
    		PublicKey:     asn1.BitString{Bytes: elliptic.Marshal(key.Curve, key.X, key.Y)},
    	})
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Oct 13 17:09:47 UTC 2023
    - 4.6K bytes
    - Viewed (0)
  8. src/crypto/elliptic/nistec.go

    		return curve.newPoint(), nil
    	}
    	// Reject values that would not get correctly encoded.
    	if x.Sign() < 0 || y.Sign() < 0 {
    		return p, errors.New("negative coordinate")
    	}
    	if x.BitLen() > curve.params.BitSize || y.BitLen() > curve.params.BitSize {
    		return p, errors.New("overflowing coordinate")
    	}
    	// Encode the coordinates and let SetBytes reject invalid points.
    	byteLen := (curve.params.BitSize + 7) / 8
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Nov 21 16:19:34 UTC 2022
    - 9.6K bytes
    - Viewed (0)
  9. src/net/netip/inlining_test.go

    		got[strings.TrimPrefix(string(match), " can inline ")] = true
    		return nil
    	})
    	wantInlinable := []string{
    		"(*uint128).halves",
    		"Addr.BitLen",
    		"Addr.hasZone",
    		"Addr.Is4",
    		"Addr.Is4In6",
    		"Addr.Is6",
    		"Addr.IsInterfaceLocalMulticast",
    		"Addr.IsValid",
    		"Addr.IsUnspecified",
    		"Addr.Less",
    		"Addr.Unmap",
    		"Addr.Zone",
    		"Addr.v4",
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jun 04 17:10:01 UTC 2024
    - 2K bytes
    - Viewed (0)
  10. src/crypto/ecdsa/ecdsa.go

    func (k *PrivateKey) ECDH() (*ecdh.PrivateKey, error) {
    	c := curveToECDH(k.Curve)
    	if c == nil {
    		return nil, errors.New("ecdsa: unsupported curve by crypto/ecdh")
    	}
    	size := (k.Curve.Params().N.BitLen() + 7) / 8
    	if k.D.BitLen() > size*8 {
    		return nil, errors.New("ecdsa: invalid private key")
    	}
    	return c.NewPrivateKey(k.D.FillBytes(make([]byte, size)))
    }
    
    func curveToECDH(c elliptic.Curve) ecdh.Curve {
    	switch c {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 00:11:18 UTC 2024
    - 20.4K bytes
    - Viewed (0)
Back to top