本文整理汇总了Golang中euphoria/io/heim/proto/security.Capability.EncryptedPayload方法的典型用法代码示例。如果您正苦于以下问题:Golang Capability.EncryptedPayload方法的具体用法?Golang Capability.EncryptedPayload怎么用?Golang Capability.EncryptedPayload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类euphoria/io/heim/proto/security.Capability
的用法示例。
在下文中一共展示了Capability.EncryptedPayload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: decryptRoomKey
func decryptRoomKey(clientKey *security.ManagedKey, capability security.Capability) (
*security.ManagedKey, error) {
if clientKey.Encrypted() {
return nil, security.ErrKeyMustBeDecrypted
}
iv, err := base64.URLEncoding.DecodeString(capability.CapabilityID())
if err != nil {
return nil, err
}
roomKeyJSON := capability.EncryptedPayload()
if err := clientKey.BlockCrypt(iv, clientKey.Plaintext, roomKeyJSON, false); err != nil {
return nil, err
}
roomKey := &security.ManagedKey{
KeyType: security.AES128,
}
if err := json.Unmarshal(clientKey.Unpad(roomKeyJSON), &roomKey.Plaintext); err != nil {
return nil, err
}
return roomKey, nil
}
示例2: Save
func (rmc *RoomManagerCapabilities) Save(
ctx scope.Context, account proto.Account, c security.Capability) error {
capRow := &Capability{
ID: c.CapabilityID(),
NonceBytes: c.Nonce(),
EncryptedPrivateData: c.EncryptedPayload(),
PublicData: c.PublicPayload(),
}
rmCapRow := &RoomManagerCapability{
Room: rmc.Room.Name,
CapabilityID: c.CapabilityID(),
Granted: time.Now(),
}
if account != nil {
capRow.AccountID = account.ID().String()
rmCapRow.AccountID = account.ID().String()
}
return rmc.Executor.Insert(capRow, rmCapRow)
}