Patch title: Release 94 bulk changes
Abstract:
File: /pliant/util/pml/resolve.pli
Key:
    Removed line
    Added line
   
module "/pliant/language/unsafe.pli"
module "/pliant/language/context.pli"
module "/pliant/protocol/dns/name.pli"
module "/pliant/fullpliant/user.pli"
module "/pliant/protocol/http/site.pli"
module "/pliant/language/type/text/str8.pli"
module "/pliant/language/type/misc/blob.pli"
module "/pliant/util/crypto/cipher.pli"


function resolve_ip class name from_ip smart ip port forward count
  arg Str class name from_ip ; arg_w Str ip ; arg CBool smart ; arg_w Int port ; arg_w CBool forward ; arg_w Int count
  plugin resolve_ip
  ip := "" ; port := undefined ; forward := false ; count := 1
  if false
    var Data:NameHost host :> name_database:data:host:computer_fullname
    if host:building<>""
      var Data:NameBuilding building :> name_database:data:building host:building
      part route_out
        each proxy building:proxy
          if proxy=computer_fullname
            leave route_out
  if class="host"
    var Data:NameHost host :> name_database:data:host:name
    if false
      if host:building<>"" and host:building<>name_database:data:host:computer_fullname:building
        var Data:NameBuilding building :> name_database:data:building host:building
    if host:ip<>""
      ip := host ip
    eif host:physical<>""
      ip := name_database:data:host:(host physical) ip
    port := host port
  eif class="site"
    var Data:Site site :> site_database:data:site:name
    if site:computer<>""
      resolve_ip "host" site:computer from_ip smart ip port forward count
      return
    ip := site ip
    port := site port    


function resolve_public_key class name -> key
  arg Str class name key
  plugin resolve_public_key
  key := ""
  if class="host"
    key := name_database:data:host:name public_key
  if class="user"
    key := user_database:data:user:name public_key
  if class="site"
    key := site_database:data:site:name public_key

function resolve_private_key class name password -> key
  arg Str class name password key
  plugin resolve_private_key
  key := ""
  if class="host"
    key := name_secret_database:data:host:name private_key
  if class="user"
    key := uncipher straight_to_Str:(user_secret_database:data:user:name private_key) password
  if class="site"
    key := site_secret_database:data:site:name private_key



function straight_to_Blob s -> b
  arg Str8 s ; arg Blob b
  b size := s len
  memory_copy s:characters b:content s:len

function straight_to_Str8 b -> s
  arg Blob b ; arg Str8 s
  s set (memory_allocate b:size addressof:s) b:size true
  memory_copy b:content s:characters b:size

function resolve_get_shared_key local_class local_name local_password remote_class remote_name remote_password -> key
  arg Str local_class local_name local_password remote_class remote_name remote_password ; arg Blob key
  plugin resolve_get_shared_key
  key size := 0
  if local_class="host" and remote_class="host"
    key := straight_to_Blob name_secret_database:data:host:local_name:session:remote_name:key
  if local_class="host" and remote_class="user"
    key := straight_to_Blob name_secret_database:data:host:local_name:user_session:remote_name:key
  if local_class="user" and remote_class="host"
    key := uncipher (straight_to_Blob user_secret_database:data:user:local_name:host_session:remote_name:key) local_password
  if local_class="site" and remote_class="user"
    key := straight_to_Blob site_secret_database:data:site:local_name:session:remote_name:key
  if local_class="user" and remote_class="site"
    key := uncipher (straight_to_Blob user_secret_database:data:user:local_name:session:remote_name:key) local_password

function resolve_set_shared_key local_class local_name local_password remote_class remote_name remote_password key
  arg Str local_class local_name local_password remote_class remote_name remote_password ; arg Blob key
  plugin resolve_set_shared_key
  if local_class="host" and remote_class="host"
    name_secret_database:data:host:local_name:session create remote_name
    name_secret_database:data:host:local_name:session:remote_name:key := straight_to_Str8 key
    name_secret_database:data:host:local_name:session:remote_name:timestamp := datetime
  if local_class="host" and remote_class="user"
    name_secret_database:data:host:local_name:user_session create remote_name
    name_secret_database:data:host:local_name:user_session:remote_name:key := straight_to_Str8 key
    name_secret_database:data:host:local_name:user_session:remote_name:timestamp := datetime
  if local_class="user" and remote_class="host"
    user_secret_database:data:user:local_name:host_session create remote_name
    user_secret_database:data:user:local_name:host_session:remote_name:key := straight_to_Str8 (cipher key remote_password)
    user_secret_database:data:user:local_name:host_session:remote_name:timestamp := datetime
    user_secret_database store
  if local_class="site" and remote_class="user"
    site_secret_database:data:site:local_name:session create remote_name
    site_secret_database:data:site:local_name:session:remote_name:key := straight_to_Str8 key
    site_secret_database:data:site:local_name:session:remote_name:timestamp := datetime
  if local_class="user" and remote_class="site"
    user_secret_database:data:user:local_name:session create remote_name
    user_secret_database:data:user:local_name:session:remote_name:key := straight_to_Str8 (cipher key remote_password)
    user_secret_database:data:user:local_name:session:remote_name:timestamp := datetime
    user_secret_database store


export resolve_ip
export resolve_public_key resolve_private_key
export resolve_get_shared_key resolve_set_shared_key