scep.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Package scep implements Simple Certificate Enrollment Protocol related functionality.
  2. package scep
  3. import (
  4. "crypto/x509"
  5. "encoding/asn1"
  6. "github.com/smallstep/pkcs7"
  7. smallscep "github.com/smallstep/scep"
  8. )
  9. // FailInfoName models the name/value of failInfo
  10. type FailInfoName smallscep.FailInfo
  11. // FailInfo models a failInfo object consisting of a
  12. // name/identifier and a failInfoText, the latter of
  13. // which can be more descriptive and is intended to be
  14. // read by humans.
  15. type FailInfo struct {
  16. Name FailInfoName
  17. Text string
  18. }
  19. // SCEP OIDs
  20. var (
  21. oidSCEPmessageType = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 2}
  22. oidSCEPpkiStatus = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 3}
  23. oidSCEPfailInfo = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 4}
  24. oidSCEPsenderNonce = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 5}
  25. oidSCEPrecipientNonce = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 6}
  26. oidSCEPtransactionID = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 7}
  27. oidSCEPfailInfoText = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 24}
  28. //oidChallengePassword = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 7}
  29. )
  30. // PKIMessage defines the possible SCEP message types
  31. type PKIMessage struct {
  32. smallscep.TransactionID
  33. smallscep.MessageType
  34. smallscep.SenderNonce
  35. *smallscep.CSRReqMessage
  36. *CertRepMessage
  37. // DER Encoded PKIMessage
  38. Raw []byte
  39. // parsed
  40. P7 *pkcs7.PKCS7
  41. // decrypted enveloped content
  42. pkiEnvelope []byte
  43. // Used to sign message
  44. Recipients []*x509.Certificate
  45. }
  46. // CertRepMessage is a type of PKIMessage
  47. type CertRepMessage struct {
  48. smallscep.PKIStatus
  49. smallscep.RecipientNonce
  50. smallscep.FailInfo
  51. Certificate *x509.Certificate
  52. degenerate []byte
  53. }