aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/go/_std_1.21/src/crypto/internal
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-02-04 13:25:53 +0300
committerAlexander Smirnov <alex@ydb.tech>2024-02-09 19:17:39 +0300
commit35d174ba70b5db9da3d0e1d26cec71fab5a37363 (patch)
treed5aae0c8954e48c74e925d3c1aa00ae15ded7c45 /contrib/go/_std_1.21/src/crypto/internal
parent871072f17990a5de95a9695926fa2a32daef2e92 (diff)
downloadydb-35d174ba70b5db9da3d0e1d26cec71fab5a37363.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/go/_std_1.21/src/crypto/internal')
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/bigmod/ya.make5
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/boring/bcache/cache.go140
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/boring/bcache/stub.s6
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/boring/bcache/ya.make8
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/boring/fipstls/ya.make0
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/boring/syso/ya.make0
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/boring/ya.make9
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/edwards25519/field/ya.make5
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/edwards25519/ya.make5
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/nistec/ya.make5
-rw-r--r--contrib/go/_std_1.21/src/crypto/internal/ya.make9
11 files changed, 0 insertions, 192 deletions
diff --git a/contrib/go/_std_1.21/src/crypto/internal/bigmod/ya.make b/contrib/go/_std_1.21/src/crypto/internal/bigmod/ya.make
index 30d178e332..99fa82d45d 100644
--- a/contrib/go/_std_1.21/src/crypto/internal/bigmod/ya.make
+++ b/contrib/go/_std_1.21/src/crypto/internal/bigmod/ya.make
@@ -13,8 +13,3 @@ ELSEIF (OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_X86_64 OR OS_WINDOWS AND
)
ENDIF()
END()
-
-
-RECURSE(
- # _asm
-)
diff --git a/contrib/go/_std_1.21/src/crypto/internal/boring/bcache/cache.go b/contrib/go/_std_1.21/src/crypto/internal/boring/bcache/cache.go
deleted file mode 100644
index 7934d03e7b..0000000000
--- a/contrib/go/_std_1.21/src/crypto/internal/boring/bcache/cache.go
+++ /dev/null
@@ -1,140 +0,0 @@
-// Copyright 2022 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 bcache implements a GC-friendly cache (see [Cache]) for BoringCrypto.
-package bcache
-
-import (
- "sync/atomic"
- "unsafe"
-)
-
-// A Cache is a GC-friendly concurrent map from unsafe.Pointer to
-// unsafe.Pointer. It is meant to be used for maintaining shadow
-// BoringCrypto state associated with certain allocated structs, in
-// particular public and private RSA and ECDSA keys.
-//
-// The cache is GC-friendly in the sense that the keys do not
-// indefinitely prevent the garbage collector from collecting them.
-// Instead, at the start of each GC, the cache is cleared entirely. That
-// is, the cache is lossy, and the loss happens at the start of each GC.
-// This means that clients need to be able to cope with cache entries
-// disappearing, but it also means that clients don't need to worry about
-// cache entries keeping the keys from being collected.
-type Cache[K, V any] struct {
- // The runtime atomically stores nil to ptable at the start of each GC.
- ptable atomic.Pointer[cacheTable[K, V]]
-}
-
-type cacheTable[K, V any] [cacheSize]atomic.Pointer[cacheEntry[K, V]]
-
-// A cacheEntry is a single entry in the linked list for a given hash table entry.
-type cacheEntry[K, V any] struct {
- k *K // immutable once created
- v atomic.Pointer[V] // read and written atomically to allow updates
- next *cacheEntry[K, V] // immutable once linked into table
-}
-
-func registerCache(unsafe.Pointer) // provided by runtime
-
-// Register registers the cache with the runtime,
-// so that c.ptable can be cleared at the start of each GC.
-// Register must be called during package initialization.
-func (c *Cache[K, V]) Register() {
- registerCache(unsafe.Pointer(&c.ptable))
-}
-
-// cacheSize is the number of entries in the hash table.
-// The hash is the pointer value mod cacheSize, a prime.
-// Collisions are resolved by maintaining a linked list in each hash slot.
-const cacheSize = 1021
-
-// table returns a pointer to the current cache hash table,
-// coping with the possibility of the GC clearing it out from under us.
-func (c *Cache[K, V]) table() *cacheTable[K, V] {
- for {
- p := c.ptable.Load()
- if p == nil {
- p = new(cacheTable[K, V])
- if !c.ptable.CompareAndSwap(nil, p) {
- continue
- }
- }
- return p
- }
-}
-
-// Clear clears the cache.
-// The runtime does this automatically at each garbage collection;
-// this method is exposed only for testing.
-func (c *Cache[K, V]) Clear() {
- // The runtime does this at the start of every garbage collection
- // (itself, not by calling this function).
- c.ptable.Store(nil)
-}
-
-// Get returns the cached value associated with v,
-// which is either the value v corresponding to the most recent call to Put(k, v)
-// or nil if that cache entry has been dropped.
-func (c *Cache[K, V]) Get(k *K) *V {
- head := &c.table()[uintptr(unsafe.Pointer(k))%cacheSize]
- e := head.Load()
- for ; e != nil; e = e.next {
- if e.k == k {
- return e.v.Load()
- }
- }
- return nil
-}
-
-// Put sets the cached value associated with k to v.
-func (c *Cache[K, V]) Put(k *K, v *V) {
- head := &c.table()[uintptr(unsafe.Pointer(k))%cacheSize]
-
- // Strategy is to walk the linked list at head,
- // same as in Get, to look for existing entry.
- // If we find one, we update v atomically in place.
- // If not, then we race to replace the start = *head
- // we observed with a new k, v entry.
- // If we win that race, we're done.
- // Otherwise, we try the whole thing again,
- // with two optimizations:
- //
- // 1. We track in noK the start of the section of
- // the list that we've confirmed has no entry for k.
- // The next time down the list, we can stop at noK,
- // because new entries are inserted at the front of the list.
- // This guarantees we never traverse an entry
- // multiple times.
- //
- // 2. We only allocate the entry to be added once,
- // saving it in add for the next attempt.
- var add, noK *cacheEntry[K, V]
- n := 0
- for {
- e := head.Load()
- start := e
- for ; e != nil && e != noK; e = e.next {
- if e.k == k {
- e.v.Store(v)
- return
- }
- n++
- }
- if add == nil {
- add = &cacheEntry[K, V]{k: k}
- add.v.Store(v)
- }
- add.next = start
- if n >= 1000 {
- // If an individual list gets too long, which shouldn't happen,
- // throw it away to avoid quadratic lookup behavior.
- add.next = nil
- }
- if head.CompareAndSwap(start, add) {
- return
- }
- noK = start
- }
-}
diff --git a/contrib/go/_std_1.21/src/crypto/internal/boring/bcache/stub.s b/contrib/go/_std_1.21/src/crypto/internal/boring/bcache/stub.s
deleted file mode 100644
index 59f2deeb60..0000000000
--- a/contrib/go/_std_1.21/src/crypto/internal/boring/bcache/stub.s
+++ /dev/null
@@ -1,6 +0,0 @@
-// Copyright 2022 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.
-
-// This file is here to silence an error about registerCache not having a body.
-// (The body is provided by package runtime.)
diff --git a/contrib/go/_std_1.21/src/crypto/internal/boring/bcache/ya.make b/contrib/go/_std_1.21/src/crypto/internal/boring/bcache/ya.make
deleted file mode 100644
index 60992b0020..0000000000
--- a/contrib/go/_std_1.21/src/crypto/internal/boring/bcache/ya.make
+++ /dev/null
@@ -1,8 +0,0 @@
-GO_LIBRARY()
-IF (OS_DARWIN AND ARCH_ARM64 OR OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_AARCH64 OR OS_LINUX AND ARCH_X86_64 OR OS_WINDOWS AND ARCH_X86_64)
- SRCS(
- cache.go
- stub.s
- )
-ENDIF()
-END()
diff --git a/contrib/go/_std_1.21/src/crypto/internal/boring/fipstls/ya.make b/contrib/go/_std_1.21/src/crypto/internal/boring/fipstls/ya.make
deleted file mode 100644
index e69de29bb2..0000000000
--- a/contrib/go/_std_1.21/src/crypto/internal/boring/fipstls/ya.make
+++ /dev/null
diff --git a/contrib/go/_std_1.21/src/crypto/internal/boring/syso/ya.make b/contrib/go/_std_1.21/src/crypto/internal/boring/syso/ya.make
deleted file mode 100644
index e69de29bb2..0000000000
--- a/contrib/go/_std_1.21/src/crypto/internal/boring/syso/ya.make
+++ /dev/null
diff --git a/contrib/go/_std_1.21/src/crypto/internal/boring/ya.make b/contrib/go/_std_1.21/src/crypto/internal/boring/ya.make
index d651bdf292..9be26e37dc 100644
--- a/contrib/go/_std_1.21/src/crypto/internal/boring/ya.make
+++ b/contrib/go/_std_1.21/src/crypto/internal/boring/ya.make
@@ -6,12 +6,3 @@ IF (OS_DARWIN AND ARCH_ARM64 OR OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_A
)
ENDIF()
END()
-
-
-RECURSE(
- bbig
- bcache
- fipstls
- sig
- syso
-)
diff --git a/contrib/go/_std_1.21/src/crypto/internal/edwards25519/field/ya.make b/contrib/go/_std_1.21/src/crypto/internal/edwards25519/field/ya.make
index c406520da9..5a08fc0959 100644
--- a/contrib/go/_std_1.21/src/crypto/internal/edwards25519/field/ya.make
+++ b/contrib/go/_std_1.21/src/crypto/internal/edwards25519/field/ya.make
@@ -17,8 +17,3 @@ ELSEIF (OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_X86_64 OR OS_WINDOWS AND
)
ENDIF()
END()
-
-
-RECURSE(
- # _asm
-)
diff --git a/contrib/go/_std_1.21/src/crypto/internal/edwards25519/ya.make b/contrib/go/_std_1.21/src/crypto/internal/edwards25519/ya.make
index 827e5b6f9e..09eccf3d8f 100644
--- a/contrib/go/_std_1.21/src/crypto/internal/edwards25519/ya.make
+++ b/contrib/go/_std_1.21/src/crypto/internal/edwards25519/ya.make
@@ -10,8 +10,3 @@ IF (OS_DARWIN AND ARCH_ARM64 OR OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_A
)
ENDIF()
END()
-
-
-RECURSE(
- field
-)
diff --git a/contrib/go/_std_1.21/src/crypto/internal/nistec/ya.make b/contrib/go/_std_1.21/src/crypto/internal/nistec/ya.make
index e6cf7d7cb7..b84525fa7a 100644
--- a/contrib/go/_std_1.21/src/crypto/internal/nistec/ya.make
+++ b/contrib/go/_std_1.21/src/crypto/internal/nistec/ya.make
@@ -27,8 +27,3 @@ ELSEIF (OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_X86_64 OR OS_WINDOWS AND
GO_EMBED_PATTERN(p256_asm_table.bin)
ENDIF()
END()
-
-
-RECURSE(
- fiat
-)
diff --git a/contrib/go/_std_1.21/src/crypto/internal/ya.make b/contrib/go/_std_1.21/src/crypto/internal/ya.make
deleted file mode 100644
index 7feea64606..0000000000
--- a/contrib/go/_std_1.21/src/crypto/internal/ya.make
+++ /dev/null
@@ -1,9 +0,0 @@
-
-RECURSE(
- alias
- bigmod
- boring
- edwards25519
- nistec
- randutil
-)