go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/server/auth/signing/signer.go (about) 1 // Copyright 2015 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package signing 16 17 import "context" 18 19 // Signer holds private key and corresponding cert and can sign blobs. 20 // 21 // It signs using RSA-256 + PKCS1v15. It usually lives in a context, see 22 // GetSigner function. 23 type Signer interface { 24 // SignBytes signs the blob with some active private key. 25 // 26 // Hashes the blob using SHA256 and then calculates RSASSA-PKCS1-v1_5 27 // signature using the currently active signing key. 28 // 29 // Returns the signature and name of the key used. 30 SignBytes(ctx context.Context, blob []byte) (keyName string, signature []byte, err error) 31 32 // Certificates returns a bundle with public certificates for all active keys. 33 // 34 // The certificates contains public keys that can be used to validate 35 // signatures generated with SignBytes. See CheckSignature method of 36 // PublicCertificates. 37 // 38 // Do not modify return value, it may be shared by many callers. 39 Certificates(ctx context.Context) (*PublicCertificates, error) 40 41 // ServiceInfo returns information about the current service. 42 // 43 // It includes app ID and the service account name (that ultimately owns the 44 // signing private key). 45 // 46 // Do not modify return value, it may be shared by many callers. 47 ServiceInfo(ctx context.Context) (*ServiceInfo, error) 48 }