 
   #-----------------------------------------
 
-  constructor : ({@version, @id, @generated, @lifetime, @mac, @key, @addr, cfg}) ->
+  constructor : ({@version, @id, @generated, @lifetime, @mac, @addr, cfg}) ->
     if cfg?
-      @key = cfg.key
+      @key = new Buffer cfg.key, 'base64' # keep the key b64-encoded in the config file
       @lifetime = cfg.lifetime unless @lifetime
 
   #-----------------------------------------


  _make_mac : (enc = null) ->
    msg = @_pack true
    key = decode @key
    hm = crypto.createHmac 'sha512', key
    hm.update msg
    hm.digest()


constants      = require './constants'
sc             = require('./status').codes
mm             = require('./mod').mgr

##=======================================================================

