Module: SCEP::ASN1

Defined in:
lib/scep/asn1.rb

Overview

Re-usable ASN1 compnents for some of the finer points of SCEP

Constant Summary collapse

MESSAGE_TYPE_PKCS_REQ =
19

Class Method Summary collapse

Class Method Details

.calculate_and_generate_pkcs7_signature_hash(data, algorithm) ⇒ Object



33
34
35
36
# File 'lib/scep/asn1.rb', line 33

def self.calculate_and_generate_pkcs7_signature_hash(data, algorithm)
  hash = OpenSSL::Digest.digest(algorithm, data)
  pkcs7_signature_hash(hash, algorithm)
end

.message_type(type = MESSAGE_TYPE_PKCS_REQ) ⇒ Object

Pre-made ASN1 value that identifies what type of message this is



14
15
16
17
18
19
20
21
# File 'lib/scep/asn1.rb', line 14

def self.message_type(type = MESSAGE_TYPE_PKCS_REQ)
  OpenSSL::ASN1::Sequence.new([
    OpenSSL::ASN1::ObjectId.new('scep-messageType'),
    OpenSSL::ASN1::Set.new([
      OpenSSL::ASN1::PrintableString.new(type.to_s)
    ])
  ])
end

.pkcs7_signature_hash(hash, algorithm_name) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/scep/asn1.rb', line 23

def self.pkcs7_signature_hash(hash, algorithm_name)
  OpenSSL::ASN1::Sequence.new([
    OpenSSL::ASN1::Sequence.new([
      OpenSSL::ASN1::ObjectId.new(algorithm_name),
      OpenSSL::ASN1::Null.new(nil)
    ]),
    OpenSSL::ASN1::OctetString.new(hash)
  ])
end