コード例 #1
0
ファイル: policyMessage.go プロジェクト: ineiti/prifi
/* Verifies that a PolicyApproveMessage has been properly constructed.
 *
 * Arguments:
 *	su         = the suite that the insurer's public key was derived from.
 *      insuredKey = the public key of the insured or the client
 *      insurerKey = the public key of the insurer or "trustee"
 *
 * Returns:
 *	whether or not the message is valid.
 */
func (msg *PolicyApprovedMessage) verifyCertificate(su abstract.Suite,
	insuredKey abstract.Point) bool {

	set := anon.Set{msg.PubKey}
	_, err := anon.Verify(su, msg.Message, set, nil, msg.Signature)
	correctMsg := msg.PubKey.String() + " insures " + insuredKey.String()
	return err == nil && correctMsg == string(msg.Message)
}
コード例 #2
0
ファイル: struct.go プロジェクト: nikirill/cothority
// NewServerIdentity creates a new ServerIdentity based on a public key and with a slice
// of IP-addresses where to find that entity. The Id is based on a
// version5-UUID which can include a URL that is based on it's public key.
func NewServerIdentity(public abstract.Point, addresses ...string) *ServerIdentity {
	url := NamespaceURL + "id/" + public.String()
	return &ServerIdentity{
		Public:    public,
		Addresses: addresses,
		ID:        ServerIdentityID(uuid.NewV5(uuid.NamespaceURL, url)),
	}
}
コード例 #3
0
ファイル: chanConnManager.go プロジェクト: ineiti/prifi
/* Adds a new connection to the connection manager
 *
 * Arguments:
 * 	theirkey = the key of the peer that this server wishes to connect to
 *
 * Returns:
 * 	An error denoting whether creating the new connection was successful.
 */
func (gcm *ChanConnManager) AddConn(theirKey abstract.Point) error {
	newConn, err := coconet.NewGoConn(gcm.dir, gcm.pubKey.String(),
		theirKey.String())
	if err != nil {
		return err
	}
	gcm.peerMap[theirKey.String()] = newConn
	return nil
}
コード例 #4
0
func (c *Coordinator) AddClient(key abstract.Point, val *net.UDPAddr) {
	// delete the client who has same ip address
	for k, v := range c.Clients {
		if v.String() == val.String() {
			delete(c.Clients, k)
			break
		}
	}
	c.Clients[key.String()] = val
}
コード例 #5
0
ファイル: policyMessage.go プロジェクト: ineiti/prifi
/* Creates a new policy-approved message
 *
 * Arguments:
 *	kp       = the private/public key of the insuring server.
 *      theirKey = the public key of the server who requested the insurance
 *
 * Returns:
 *	A new policy approved message.
 *
 * NOTE:
 *	The approved certificate is a string of the form:
 *     		"My_Public_Key insures Their_Public_Key"
 *
 *	It will always be of this form for easy validation.
 */
func (msg *PolicyApprovedMessage) createMessage(kp *config.KeyPair,
	theirKey abstract.Point) *PolicyApprovedMessage {

	set := anon.Set{kp.Public}
	approveMsg := kp.Public.String() + " insures " + theirKey.String()
	msg.PubKey = kp.Public
	msg.Message = []byte(approveMsg)
	msg.Signature = anon.Sign(kp.Suite, random.Stream, msg.Message,
		set, nil, 0, kp.Secret)
	return msg
}
コード例 #6
0
ファイル: chanConnManager.go プロジェクト: ineiti/prifi
/* Get a message from a given peer.
 *
 * Arguments:
 *	 p = the public key of the origin
 *	 bum = a buffer for receiving the message
 *
 * Returns:
 *	An error denoting whether the get to the buffer was successfull
 */
func (gcm ChanConnManager) Get(p abstract.Point, bum coconet.BinaryUnmarshaler) error {
	return gcm.peerMap[p.String()].Get(bum)
}
コード例 #7
0
ファイル: chanConnManager.go プロジェクト: ineiti/prifi
/* Put a message to a given peer.
 *
 * Arguments:
 * 	p = the public key of the destination
 * 	data = the message to send
 *
 * Returns:
 * 	An error denoting whether the put was successfull
 */
func (gcm *ChanConnManager) Put(p abstract.Point, data coconet.BinaryMarshaler) error {
	return gcm.peerMap[p.String()].Put(data)
}
コード例 #8
0
func (c *Coordinator) AddIntoRepMap(key abstract.Point, val []byte) {
	keyStr := key.String()
	c.ReputationKeyMap[keyStr] = key
	c.ReputationMap[keyStr] = val
}
コード例 #9
0
func (c *Coordinator) AddIntoDecryptedMap(key abstract.Point, val int) {
	keyStr := key.String()
	c.DecryptedKeysMap[keyStr] = key
	c.DecryptedReputationMap[keyStr] = val
}
コード例 #10
0
// get reputation
func (c *Coordinator) GetReputation(key abstract.Point) int {
	return c.DecryptedReputationMap[key.String()]
}