func InitClient(name string, pwd []byte) (Client, error) {
	clientMutex.Lock()
	defer clientMutex.Unlock()
	log.Info("Initializing client [%s]...", name)
	if entry, ok := clients[name]; ok {
		log.Info("Client already initiliazied [%s]. Increasing counter from [%d]", name, clients[name].counter)
		entry.counter++
		clients[name] = entry
		return clients[name].client, nil
	}
	client := new(clientImpl)
	if err := client.init(name, pwd); err != nil {
		log.Error("Failed client initialization [%s]: [%s].", name, err)
		return nil, err
	}
	clients[name] = clientEntry{client, 1}
	log.Info("Initializing client [%s]...done!", name)
	return client, nil
}
InitClient initializes a client named name with password pwd
package crypto
import (
	"github.com/openblockchain/obc-peer/openchain/crypto/utils"
	"sync"
)
type clientEntry struct {
	client  Client
	counter int64
}
var (
	clients = make(map[string]clientEntry)
	clientMutex sync.Mutex
)
func RegisterClient(name string, pwd []byte, enrollID, enrollPWD string) error {
	clientMutex.Lock()
	defer clientMutex.Unlock()
	log.Info("Registering client [%s] with name [%s]...", enrollID, name)
	if _, ok := clients[name]; ok {
		log.Info("Registering client [%s] with name [%s]...done. Already initialized.", enrollID, name)
		return nil
	}
	client := new(clientImpl)
	if err := client.register(name, pwd, enrollID, enrollPWD); err != nil {
		if err != utils.ErrAlreadyRegistered && err != utils.ErrAlreadyInitialized {
			log.Error("Failed registering client [%s] with name [%s] [%s].", enrollID, name, err)
			return err
		}
		log.Info("Registering client [%s] with name [%s]...done. Already registered or initiliazed.", enrollID, name)
	}
	err := client.close()
	if err != nil {
		log.Warning("Registering client [%s] with name [%s]. Failed closing [%s].", enrollID, name, err)
	}
	log.Info("Registering client [%s] with name [%s]...done!", enrollID, name)
	return nil
}