Example #1
0
func (spriv *ServerPrivate) ParseFrom(unparsed map[string]string, acked map[string]bool) error {
	if err := spriv.EndpointParams.ParseFrom(unparsed, acked); err != nil {
		return err
	}

	privateStr, present := unparsed[paramPrivateKey]
	if !present {
		return ErrNoPrivateKey
	}
	private, err := prim.LoadPrivateText(privateStr)
	if err != nil {
		return err
	}
	acked[paramPrivateKey] = true

	opaqueStr, present := unparsed[paramOpaqueId]
	if !present {
		return ErrNoOpaqueId
	}
	opaqueId, err := crypting.LoadOpaqueIdText(opaqueStr)
	if err != nil {
		return err
	}
	acked[paramOpaqueId] = true

	spriv.LongtermPrivate = private
	spriv.OpaqueId = *opaqueId
	return nil
}
Example #2
0
func (spub *ServerPublic) ParseFrom(unparsed map[string]string, acked map[string]bool) error {
	if err := spub.EndpointParams.ParseFrom(unparsed, acked); err != nil {
		return err
	}

	publicStr, present := unparsed[paramPublicKey]
	if !present {
		return ErrNoPublicKey
	}
	public, err := prim.LoadPublicText(publicStr)
	if err != nil {
		return err
	}
	acked[paramPublicKey] = true

	opaqueStr, present := unparsed[paramOpaqueId]
	if !present {
		return ErrNoOpaqueId
	}
	opaqueId, err := crypting.LoadOpaqueIdText(opaqueStr)
	if err != nil {
		return err
	}
	acked[paramOpaqueId] = true

	spub.LongtermPublic = public
	spub.OpaqueId = *opaqueId
	return nil
}