On Mon, 15 Oct 2001, Rich Kilmer wrote:

> I agree about plugable cryptographic service providers!
> 
> What about the syntax:
> 
> 	crypt = Crypto["Blowfish"].new
> 
In line with Nat's recent post this is unnecessary. From what I understand
a crypto service provider is simply a set of actual ciphers/algs in
different groups/categories. So, if you really want them:

# Ok, this is the lazy way maybe you should have fixed service names
class CryptoServiceProvider
  def initialize(aHash)
    @services = aHash)
  end

  def method_missing(methodId, *args)
    @services[methodId].new(*args)
  end
end

kilmer_cps = CryptoServiceProvider.new(:block_cipher => Blowfish,
                                       :digest => SHA1)
kilmer_cps.block_cipher(arg1, arg2, ...)
kilmer_cps.digest(...)

or you can even do

class BlockCipher < Cipher
  def BlockCipher.new(*args)
    cps.block_cipher(*args)
  end
end

def cps; $cps; end
def cps=(cps); $cps=cps; end

if you really want to allow the users of cryptography to be unaware /
dont care about what alg implements the crypto service. But, hey, its a
global in there!

All of this is probably bogus since I know almost nothing about the
cryptography service providers of Java and similar API's. And I don't
think the design above is good or Rubyequse; just trying to mimic
something in Ruby...

The right way is probably simply to do an ordinary class hierarchy (Cipher
> ((BlockCipher > (Blowfish, ...)), (StreamCipher > ...) etc) and then
have CSP as a sort of convenience API and different CSP subclasses
collecting alg's of similar strength etc. Or have I totally misunderstood
the CSP idea?

Regards,

Robert