Cryptosystem.go 848 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package types
  2. import "encoding/asn1"
  3. // Reference: https://www.ietf.org/rfc/rfc4120.txt
  4. // Section: 5.2.9
  5. // Reference: https://www.ietf.org/rfc/rfc3961.txt
  6. type EncryptedData struct {
  7. EType int `asn1:"explicit,tag:0"`
  8. KVNO int `asn1:"explicit,optional,tag:1"`
  9. Cipher []byte `asn1:"explicit,tag:2"`
  10. }
  11. //AKA KeyBlock
  12. type EncryptionKey struct {
  13. KeyType int `asn1:"explicit,tag:0"`
  14. KeyValue []byte `asn1:"explicit,tag:1"`
  15. }
  16. type Checksum struct {
  17. CksumType int `asn1:"explicit,tag:0"`
  18. Checksum []byte `asn1:"explicit,tag:1"`
  19. }
  20. func (a *EncryptedData) Unmarshal(b []byte) error {
  21. _, err := asn1.Unmarshal(b, a)
  22. return err
  23. }
  24. func (a *EncryptionKey) Unmarshal(b []byte) error {
  25. _, err := asn1.Unmarshal(b, a)
  26. return err
  27. }
  28. func (a *Checksum) Unmarshal(b []byte) error {
  29. _, err := asn1.Unmarshal(b, a)
  30. return err
  31. }