-
Notifications
You must be signed in to change notification settings - Fork 277
Expand file tree
/
Copy pathsign.go
More file actions
27 lines (22 loc) · 1006 Bytes
/
sign.go
File metadata and controls
27 lines (22 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package signer
import (
"github.com/langgenius/dify-plugin-daemon/internal/core/license/private_key"
"github.com/langgenius/dify-plugin-daemon/internal/utils/encryption"
"github.com/langgenius/dify-plugin-daemon/pkg/plugin_packager/decoder"
"github.com/langgenius/dify-plugin-daemon/pkg/plugin_packager/signer/withkey"
)
/*
DifyPlugin is a file type that represents a plugin, it's designed to based on zip file format.
When signing a plugin, we use RSA-4096 to create a signature for the plugin and write the signature
into comment field of the zip file.
*/
// SignPlugin is a function that signs a plugin
// It takes a plugin as a stream of bytes and signs it with RSA-4096 with a bundled private key
func SignPlugin(plugin []byte, verification *decoder.Verification) ([]byte, error) {
// load private key
privateKey, err := encryption.LoadPrivateKey(private_key.PRIVATE_KEY)
if err != nil {
return nil, err
}
return withkey.SignPluginWithPrivateKey(plugin, verification, privateKey)
}