Class: RStyx::Keyring::Certificate

Inherits:
Object
  • Object
show all
Defined in:
lib/rstyx/keyring.rb

Overview

An Inferno certificate.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sa, ha, signer, exp, rsa) ⇒ Certificate

Create a new certificate instance given the signature algorithm sa, the hash algorithm ha, the signer name signer, the expiration date exp and the signature data rsa.



353
354
355
356
357
358
359
# File 'lib/rstyx/keyring.rb', line 353

def initialize(sa, ha, signer, exp, rsa)
  @sa = sa
  @ha = ha
  @signer = signer
  @exp = exp
  @rsa = rsa
end

Instance Attribute Details

#expObject

Expiration date



342
343
344
# File 'lib/rstyx/keyring.rb', line 342

def exp
  @exp
end

#haObject

Hash algorithm



335
336
337
# File 'lib/rstyx/keyring.rb', line 335

def ha
  @ha
end

#rsaObject

The signature data itself



346
347
348
# File 'lib/rstyx/keyring.rb', line 346

def rsa
  @rsa
end

#saObject

Signature algorithm



332
333
334
# File 'lib/rstyx/keyring.rb', line 332

def sa
  @sa
end

#signerObject

Name of signer



338
339
340
# File 'lib/rstyx/keyring.rb', line 338

def signer
  @signer
end

Class Method Details

.from_s(s) ⇒ Object

Create a new Certificate, given a certificate record string such as might be read from an Inferno keyring file.



365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/rstyx/keyring.rb', line 365

def self.from_s(s)
  a = s.split("\n")
  if a.length < 5
    raise InvalidCertificateException.new("bad certificate syntax")
  end

  sa = a[0]
  ha = a[1]
  signer = a[2]
  exp = a[3].to_i
  rsa = Keyring.s2big(a[4])
  return(Certificate.new(sa, ha, signer, exp, rsa))
end

Instance Method Details

#to_sObject

Return the certificate information as a string suitable for writing as a protocol message or in the Inferno keyfile format.



382
383
384
385
386
387
388
389
390
391
# File 'lib/rstyx/keyring.rb', line 382

def to_s
  str = <<EOS
#{@sa}
#{@ha}
#{@signer}
#{@exp}
#{Keyring.big2s(@rsa)}
EOS
  return(str)
end