// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.2
// - protoc             (unknown)
// source: signer/signer.proto

package signer

import (
	context "context"

	grpc "google.golang.org/grpc"
	codes "google.golang.org/grpc/codes"
	status "google.golang.org/grpc/status"
	emptypb "google.golang.org/protobuf/types/known/emptypb"
)

// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9

const (
	SignerService_GetCertificate_FullMethodName = "/signerapi.SignerService/GetCertificate"
	SignerService_GetPublicKey_FullMethodName   = "/signerapi.SignerService/GetPublicKey"
	SignerService_Sign_FullMethodName           = "/signerapi.SignerService/Sign"
)

// SignerServiceClient is the client API for SignerService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// SignerService is implemented by an out-of-process SecureBoot/PCR signer.
//
// The Talos imager opens a gRPC client connection to the signer's Unix
// socket and calls these RPCs to fetch the signing certificate / public
// key and to sign digests of the artifacts being built.
//
// A YubiKey-based example implementation is available at:
// https://github.com/jaakkonen/talos-secureboot
//
// Conventions:
//   - SecureBoot signing requires GetCertificate (the cert is embedded in
//     the PE Authenticode signature so UEFI firmware can verify it). The
//     public key is read from the certificate.
//   - PCR signing requires GetPublicKey only (the public RSA key is
//     embedded in the UKI's .pcrpkey section). GetCertificate is unused.
//   - Sign always operates on a precomputed digest. The hash and scheme
//     are declared in the request so the helper can route to the correct
//     HSM primitive (RSA-PKCS1v15 / RSA-PSS).
type SignerServiceClient interface {
	// GetCertificate returns the X.509 certificate associated with the
	// signing key, PEM-encoded.
	GetCertificate(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*CertificateResponse, error)
	// GetPublicKey returns the public key associated with the signing key,
	// PEM-encoded as a SubjectPublicKeyInfo (PKIX) block.
	GetPublicKey(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*PublicKeyResponse, error)
	// Sign produces a signature over the supplied digest.
	Sign(ctx context.Context, in *SignRequest, opts ...grpc.CallOption) (*SignResponse, error)
}

type signerServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewSignerServiceClient(cc grpc.ClientConnInterface) SignerServiceClient {
	return &signerServiceClient{cc}
}

func (c *signerServiceClient) GetCertificate(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*CertificateResponse, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(CertificateResponse)
	err := c.cc.Invoke(ctx, SignerService_GetCertificate_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *signerServiceClient) GetPublicKey(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*PublicKeyResponse, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(PublicKeyResponse)
	err := c.cc.Invoke(ctx, SignerService_GetPublicKey_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *signerServiceClient) Sign(ctx context.Context, in *SignRequest, opts ...grpc.CallOption) (*SignResponse, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(SignResponse)
	err := c.cc.Invoke(ctx, SignerService_Sign_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// SignerServiceServer is the server API for SignerService service.
// All implementations must embed UnimplementedSignerServiceServer
// for forward compatibility.
//
// SignerService is implemented by an out-of-process SecureBoot/PCR signer.
//
// The Talos imager opens a gRPC client connection to the signer's Unix
// socket and calls these RPCs to fetch the signing certificate / public
// key and to sign digests of the artifacts being built.
//
// A YubiKey-based example implementation is available at:
// https://github.com/jaakkonen/talos-secureboot
//
// Conventions:
//   - SecureBoot signing requires GetCertificate (the cert is embedded in
//     the PE Authenticode signature so UEFI firmware can verify it). The
//     public key is read from the certificate.
//   - PCR signing requires GetPublicKey only (the public RSA key is
//     embedded in the UKI's .pcrpkey section). GetCertificate is unused.
//   - Sign always operates on a precomputed digest. The hash and scheme
//     are declared in the request so the helper can route to the correct
//     HSM primitive (RSA-PKCS1v15 / RSA-PSS).
type SignerServiceServer interface {
	// GetCertificate returns the X.509 certificate associated with the
	// signing key, PEM-encoded.
	GetCertificate(context.Context, *emptypb.Empty) (*CertificateResponse, error)
	// GetPublicKey returns the public key associated with the signing key,
	// PEM-encoded as a SubjectPublicKeyInfo (PKIX) block.
	GetPublicKey(context.Context, *emptypb.Empty) (*PublicKeyResponse, error)
	// Sign produces a signature over the supplied digest.
	Sign(context.Context, *SignRequest) (*SignResponse, error)
	mustEmbedUnimplementedSignerServiceServer()
}

// UnimplementedSignerServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedSignerServiceServer struct{}

func (UnimplementedSignerServiceServer) GetCertificate(context.Context, *emptypb.Empty) (*CertificateResponse, error) {
	return nil, status.Error(codes.Unimplemented, "method GetCertificate not implemented")
}
func (UnimplementedSignerServiceServer) GetPublicKey(context.Context, *emptypb.Empty) (*PublicKeyResponse, error) {
	return nil, status.Error(codes.Unimplemented, "method GetPublicKey not implemented")
}
func (UnimplementedSignerServiceServer) Sign(context.Context, *SignRequest) (*SignResponse, error) {
	return nil, status.Error(codes.Unimplemented, "method Sign not implemented")
}
func (UnimplementedSignerServiceServer) mustEmbedUnimplementedSignerServiceServer() {}
func (UnimplementedSignerServiceServer) testEmbeddedByValue()                       {}

// UnsafeSignerServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to SignerServiceServer will
// result in compilation errors.
type UnsafeSignerServiceServer interface {
	mustEmbedUnimplementedSignerServiceServer()
}

func RegisterSignerServiceServer(s grpc.ServiceRegistrar, srv SignerServiceServer) {
	// If the following call panics, it indicates UnimplementedSignerServiceServer was
	// embedded by pointer and is nil.  This will cause panics if an
	// unimplemented method is ever invoked, so we test this at initialization
	// time to prevent it from happening at runtime later due to I/O.
	if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
		t.testEmbeddedByValue()
	}
	s.RegisterService(&SignerService_ServiceDesc, srv)
}

func _SignerService_GetCertificate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(emptypb.Empty)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(SignerServiceServer).GetCertificate(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: SignerService_GetCertificate_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(SignerServiceServer).GetCertificate(ctx, req.(*emptypb.Empty))
	}
	return interceptor(ctx, in, info, handler)
}

func _SignerService_GetPublicKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(emptypb.Empty)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(SignerServiceServer).GetPublicKey(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: SignerService_GetPublicKey_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(SignerServiceServer).GetPublicKey(ctx, req.(*emptypb.Empty))
	}
	return interceptor(ctx, in, info, handler)
}

func _SignerService_Sign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(SignRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(SignerServiceServer).Sign(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: SignerService_Sign_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(SignerServiceServer).Sign(ctx, req.(*SignRequest))
	}
	return interceptor(ctx, in, info, handler)
}

// SignerService_ServiceDesc is the grpc.ServiceDesc for SignerService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var SignerService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "signerapi.SignerService",
	HandlerType: (*SignerServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetCertificate",
			Handler:    _SignerService_GetCertificate_Handler,
		},
		{
			MethodName: "GetPublicKey",
			Handler:    _SignerService_GetPublicKey_Handler,
		},
		{
			MethodName: "Sign",
			Handler:    _SignerService_Sign_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "signer/signer.proto",
}
