-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding progress so far - a bit of a mess
Signed-off-by: chaosinthecrd <[email protected]>
- Loading branch information
1 parent
cfee7c9
commit 5d16222
Showing
12 changed files
with
132 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package dsse | ||
|
||
import ( | ||
"crypto" | ||
"fmt" | ||
|
||
"github.com/in-toto/go-witness/cryptoutil" | ||
idsse "github.com/in-toto/go-witness/dsse" | ||
"github.com/secure-systems-lab/go-securesystemslib/dsse" | ||
) | ||
|
||
type DSSEEnvelope struct { | ||
Envelope *dsse.Envelope | ||
} | ||
|
||
func (e *DSSEEnvelope) Sign(signer *crypto.Signer, opts ...cryptoutil.SignerOption) (interface{}, error) { | ||
if e.Envelope.PayloadType == "" || e.Envelope.Payload == "" { | ||
return nil, fmt.Errorf("PayloadType and Payload not populated correctly") | ||
} | ||
|
||
s, err := cryptoutil.NewSigner(signer) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
v, err := cryptoutil.NewVerifier(signer) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
sv := cryptoutil.SignerVerifier{ | ||
Signer: s, | ||
Verifier: v, | ||
} | ||
|
||
se, err := idsse.Sign(e.Envelope.PayloadType, []byte(e.Envelope.Payload), idsse.SignWithSigners(sv.Signer)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return se, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package envelope | ||
|
||
import ( | ||
"crypto" | ||
|
||
"github.com/in-toto/go-witness/cryptoutil" | ||
) | ||
|
||
// Envelope provides basic functions to manipulate signatures. | ||
type Envelope interface { | ||
// Sign generates and sign the envelope according to the sign request. | ||
Sign(signer *crypto.Signer, opts ...cryptoutil.SignerOption) (interface{}, error) | ||
|
||
// Verify verifies the envelope and returns its enclosed payload and signer | ||
// info. | ||
Verify(pub *crypto.PublicKey, opts ...cryptoutil.VerifierOption) (interface{}, error) | ||
|
||
// Content returns the payload and signer information of the envelope. | ||
// Content is trusted only after the successful call to `Verify()`. | ||
Content() ([]byte, error) | ||
} |