def setup_brand(brand_identifier): """ create keys, brand config file, and brand layers file for NUS """ base_id, base_keypair = get_base() brand_id, brand_keypair = make_keypair() save_key(brand_id, brand_keypair) layers = ( (brand_id, brand_keypair.publickey(), ), (base_id, base_keypair.publickey(), ), ) layer_fn = os.path.join(_ESCROW_LAYERS_PATH, "brand.%s.layers.serial" % ( brand_identifier, )) if os.path.exists(layer_fn): raise EscrowError("Brand id %s layers exist" % (brand_identifier, )) with open(layer_fn, "ab") as fobj: dump(layers, fobj) write_config("brand.%s" % (brand_identifier, ), brand_id) print "new keys and config saved for brand %s" % brand_identifier return brand_id, brand_identifier, layers
def setup_brand(brand_identifier): """ create keys, brand config file, and brand layers file for NUS """ base_id, base_keypair = get_base() brand_id, brand_keypair = make_keypair() save_key(brand_id, brand_keypair) layers = ( ( brand_id, brand_keypair.publickey(), ), ( base_id, base_keypair.publickey(), ), ) layer_fn = os.path.join(_ESCROW_LAYERS_PATH, "brand.%s.layers.serial" % (brand_identifier, )) if os.path.exists(layer_fn): raise EscrowError("Brand id %s layers exist" % (brand_identifier, )) with open(layer_fn, "ab") as fobj: dump(layers, fobj) write_config("brand.%s" % (brand_identifier, ), brand_id) print "new keys and config saved for brand %s" % brand_identifier return brand_id, brand_identifier, layers
def save_key(key_id, keypair): """ save (key id, keypair, ) for key id """ key_fn = os.path.join(_ESCROW_KEYS_PATH, "%s.key" % (key_id, )) with open(key_fn, "ab") as fobj: dump((key_id, keypair, ), fobj) print "Saved %s to %s" % ( key_id, key_fn, ) return True
def save_key(key_id, keypair): """ save (key id, keypair, ) for key id """ key_fn = os.path.join(_ESCROW_KEYS_PATH, "%s.key" % (key_id, )) with open(key_fn, "ab") as fobj: dump(( key_id, keypair, ), fobj) print "Saved %s to %s" % ( key_id, key_fn, ) return True