summaryrefslogtreecommitdiffstats
path: root/modules/util
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-05-12 19:27:50 +0200
committerGitHub <noreply@github.com>2023-05-12 17:27:50 +0000
commit9173e079ae9ddf18685216fd846ca1727297393c (patch)
tree3437a68d48c338f5721146e951f553fb40facbab /modules/util
parent80bde0141bb4a04b65b399b40ab547bf56c0567e (diff)
downloadgitea-9173e079ae9ddf18685216fd846ca1727297393c.tar.gz
gitea-9173e079ae9ddf18685216fd846ca1727297393c.zip
Add Alpine package registry (#23714)
This PR adds an Alpine package registry. You can follow [this tutorial](https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package) to build a *.apk package for testing. This functionality is similar to the Debian registry (#22854) and therefore shares some methods. I marked this PR as blocked because it should be merged after #22854. ![grafik](https://user-images.githubusercontent.com/1666336/227779595-b76163aa-eea1-4a79-9583-775c24ad74e8.png) --------- Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'modules/util')
-rw-r--r--modules/util/keypair.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/util/keypair.go b/modules/util/keypair.go
index 5a3ce715a4..97f2d9ebca 100644
--- a/modules/util/keypair.go
+++ b/modules/util/keypair.go
@@ -4,10 +4,13 @@
package util
import (
+ "crypto"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
+
+ "github.com/minio/sha256-simd"
)
// GenerateKeyPair generates a public and private keypair
@@ -43,3 +46,16 @@ func pemBlockForPub(pub *rsa.PublicKey) (string, error) {
})
return string(pubBytes), nil
}
+
+// CreatePublicKeyFingerprint creates a fingerprint of the given key.
+// The fingerprint is the sha256 sum of the PKIX structure of the key.
+func CreatePublicKeyFingerprint(key crypto.PublicKey) ([]byte, error) {
+ bytes, err := x509.MarshalPKIXPublicKey(key)
+ if err != nil {
+ return nil, err
+ }
+
+ checksum := sha256.Sum256(bytes)
+
+ return checksum[:], nil
+}