lib/sp_store/p_chip/soft_boot_logic.rb
def boot_finish(root_hash, state_hmac, encrypted_endorsement_key)
    # State check.
    raise RuntimeError, 'Already called boot_finish' if @root_hash

    # Argument check.
    if Crypto.hmac(@p_key, [root_hash, @boot_nonce].join) != state_hmac
      raise RuntimeError, 'State HMAC check failed'
    end
    endorsement_key = nil
    begin
      endorsement_key = Crypto.key_pair(
          Crypto.sk_decrypt(@p_key, encrypted_endorsement_key))
    rescue OpenSSL::PKey::RSAError
      raise RuntimeError, 'Invalid endorsement key'
    end
    if endorsement_key[:public].inspect !=
       @endorsement_certificate.public_key.inspect
      raise RuntimeError, 'Endorsement key does not match certificate'
    end
    
    # State transition.
    @endorsement_key = endorsement_key
    @root_hash = root_hash
    @observer.booted @root_hash, @endorsement_key
  end
# Instantiates a software model of the P chip's boot logic module.
#
# Args:
#   p_key:: the P chip's symmetric key; was generated during the manufacturing
#           process
#   ca_public_key:: the public key of the S-P chip pair's manufacturer root
#                   CA; this is burned in the P chip's ROM
#   observer:: receives call to booted and reset as part of the boot process
Instantiates a software model of the P chip's boot logic module.
Instantiates a software model of the P chip ' s boot logic module .
def boot_finish(root_hash, state_hmac, encrypted_endorsement_key)
    raise RuntimeError, 'Already called boot_finish' if @root_hash
    if Crypto.hmac(@p_key, [root_hash, @boot_nonce].join) != state_hmac
      raise RuntimeError, 'State HMAC check failed'
    end
    endorsement_key = nil
    begin
      endorsement_key = Crypto.key_pair(
          Crypto.sk_decrypt(@p_key, encrypted_endorsement_key))
    rescue OpenSSL::PKey::RSAError
      raise RuntimeError, 'Invalid endorsement key'
    end
    if endorsement_key[:public].inspect !=
       @endorsement_certificate.public_key.inspect
      raise RuntimeError, 'Endorsement key does not match certificate'
    end
    @endorsement_key = endorsement_key
    @root_hash = root_hash
    @observer.booted @root_hash, @endorsement_key
  end
def boot_finish ( root_hash , state_hmac , encrypted_endorsement_key ) raise RuntimeError , 'Already called boot_finish' if @root_hash if Crypto . hmac ( @p_key , [ root_hash , @boot_nonce ] . join ) != state_hmac raise RuntimeError , 'State HMAC check failed' end endorsement_key = nil begin endorsement_key = Crypto . key_pair ( Crypto . sk_decrypt ( @p_key , encrypted_endorsement_key ) ) rescue OpenSSL :: PKey :: RSAError raise RuntimeError , 'Invalid endorsement key' end if endorsement_key [ :public ] . inspect != @endorsement_certificate . public_key . inspect raise RuntimeError , 'Endorsement key does not match certificate' end @endorsement_key = endorsement_key @root_hash = root_hash @observer . booted @root_hash , @endorsement_key end
Instantiates a software model of the P chip's boot logic module.
Instantiates a software model of the P chip ' s boot logic module .
# State check. # Argument check. # State transition.
root_hash
state_hmac
encrypted_endorsement_key