Skip to content

Commit

Permalink
add ASN1Sign
Browse files Browse the repository at this point in the history
  • Loading branch information
ah-its-andy committed Nov 20, 2017
1 parent 11bb3c1 commit 4df8a32
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions rsa_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package signer

type RSAClient interface {
Sign(input []byte) ([]byte, string, error)
ASN1Sign(typ string, payloads ...string) ([]byte, string, error)
}
15 changes: 15 additions & 0 deletions x509_rsa_client.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package signer

import (
"encoding/pem"
"strings"
)

type x509RSAClient struct {
server RSAServer
descriptor RSADescriptor
Expand All @@ -14,3 +19,13 @@ func (p *x509RSAClient) Sign(input []byte) ([]byte, string, error) {
}
return signature, p.descriptor.Certificate(), nil
}

func (p *x509RSAClient) ASN1Sign(typ string, payloads ...string) ([]byte, string, error) {
payload := strings.Join(payloads, "\r\n")
block := &pem.Block{
Type: strings.ToUpper(typ),
Bytes: []byte(payload),
}
asn1Str := pem.EncodeToMemory(block)
return p.Sign(asn1Str)
}

0 comments on commit 4df8a32

Please sign in to comment.