非对称密码学和 JWT
Asymmetric cryptography and JWT
我正在尝试了解 JWT 是如何在我正在审查的代码库中实现的。我读 this and this
然而,在这个代码库中,客户端似乎有私钥和 public 密钥......它有服务器的 public 密钥和它自己的私钥(我假设服务器有对应的私钥)。为什么这是必要的?客户端不应该只需要 public 密钥而服务器只需要私钥吗?如果客户端正在加密一条消息,难道它不能使用 public 密钥来加密它而服务器只需要私钥来解密它吗?相反,它不能用 public 密钥从服务器解密加密消息吗?为什么客户端需要两套 public 和私钥?
来自阅读:
To create a digital signature, signing software (such as an email program) creates a one-way hash of the electronic data to be signed. The user's private key is then used to encrypt the hash, returning a value that is unique to the hashed data. The encrypted hash, along with other information such as the hashing algorithm, forms the digital signature. Any change in the data, even to a single bit, results in a different hash value. This attribute enables others to validate the integrity of the data by using the signer's public key to decrypt the hash. If the decrypted hash matches a second computed hash of the same data, it proves that the data hasn't changed since it was signed.
哈希数据和加密数据有什么区别?为什么你需要先散列它?哈希数据是否加密?
第二个计算出的哈希值从何而来?如果解密器试图将 public 密钥应用于加密数据......它如何知道它成功了?它与什么相比?该比较哈希从何而来?
JWT 使用发送方的私钥签名(未加密)。可以选择使用 JWE 对 jWT 内容进行加密。
对称密钥用于签名和验证。使用非对称密钥对,消息用私钥签名并用 public 验证。
数字签名可保护邮件免遭篡改并识别发件人。非对称密钥允许接收方使用发送方的 public 密钥验证签名,而不会危及私钥
JWT 签名可根据用途在客户端或服务器端使用。例如,在身份验证流程中
客户端:API 请求,其中服务器使用注册期间上传的 public 密钥验证签名
服务器端:出示凭据后向最终用户颁发令牌
在内部,数字签名涉及多个加密操作、摘要消息、加密散列并添加算法标识符。但是你不用担心这个,因为所有的编程语言都支持它
我试图笼统地解释 JWT 和数字签名,而不是回答您的具体问题。我可能留下了一些。请评论
我正在尝试了解 JWT 是如何在我正在审查的代码库中实现的。我读 this and this
然而,在这个代码库中,客户端似乎有私钥和 public 密钥......它有服务器的 public 密钥和它自己的私钥(我假设服务器有对应的私钥)。为什么这是必要的?客户端不应该只需要 public 密钥而服务器只需要私钥吗?如果客户端正在加密一条消息,难道它不能使用 public 密钥来加密它而服务器只需要私钥来解密它吗?相反,它不能用 public 密钥从服务器解密加密消息吗?为什么客户端需要两套 public 和私钥?
来自阅读:
To create a digital signature, signing software (such as an email program) creates a one-way hash of the electronic data to be signed. The user's private key is then used to encrypt the hash, returning a value that is unique to the hashed data. The encrypted hash, along with other information such as the hashing algorithm, forms the digital signature. Any change in the data, even to a single bit, results in a different hash value. This attribute enables others to validate the integrity of the data by using the signer's public key to decrypt the hash. If the decrypted hash matches a second computed hash of the same data, it proves that the data hasn't changed since it was signed.
哈希数据和加密数据有什么区别?为什么你需要先散列它?哈希数据是否加密?
第二个计算出的哈希值从何而来?如果解密器试图将 public 密钥应用于加密数据......它如何知道它成功了?它与什么相比?该比较哈希从何而来?
JWT 使用发送方的私钥签名(未加密)。可以选择使用 JWE 对 jWT 内容进行加密。
对称密钥用于签名和验证。使用非对称密钥对,消息用私钥签名并用 public 验证。
数字签名可保护邮件免遭篡改并识别发件人。非对称密钥允许接收方使用发送方的 public 密钥验证签名,而不会危及私钥
JWT 签名可根据用途在客户端或服务器端使用。例如,在身份验证流程中
客户端:API 请求,其中服务器使用注册期间上传的 public 密钥验证签名
服务器端:出示凭据后向最终用户颁发令牌
在内部,数字签名涉及多个加密操作、摘要消息、加密散列并添加算法标识符。但是你不用担心这个,因为所有的编程语言都支持它
我试图笼统地解释 JWT 和数字签名,而不是回答您的具体问题。我可能留下了一些。请评论