3个版本
0.1.2 | 2022年8月15日 |
---|---|
0.1.1 | 2022年8月14日 |
0.1.0 | 2022年8月13日 |
#1297 in 加密学
每月141次下载
17KB
277 行
cognito_srp

纯Rust实现的AWS cognito SRP密码认证密钥交换算法。
该库是将Python warrant库的加密部分移植,并使用不同的接口。
该库尚未准备好用于生产。
安全警告
代码尚未进行安全风险评估,实现可能不正确。
自行承担风险!
最低支持的Rust版本
Rust 1.56 或更高。
许可证
该包受
使用
实例化一个SrpClient
,使用get_auth_params
函数进行SDK cognito idp initiate_auth
挑战响应流程的初始化步骤
使用process_challenge
生成对服务器挑战的响应。
let srp_client = SrpClient::new();
let srp_client = SrpClient::new(
"COGNITO_USERNAME",
"COGNITO_PASSWORD",
"COGNITO_POOL_ID",
"COGNITO_CLIENT_ID",
None,
);
let auth_init_res = cognito_client
.initiate_auth()
.auth_flow(AuthFlowType::UserSrpAuth)
.client_id("cognito client id".to_string())
.set_auth_parameters(Some(srp_client.get_auth_params().unwrap()))
.send()
.await;
let auth_init_out = auth_init_res.unwrap();
let challenge_params =
auth_init_out
.challenge_parameters
.unwrap();
let challenge_responses =
srp_client.process_challenge(challenge_params).unwrap();
let password_challenge_result = cognito_client
.respond_to_auth_challenge()
.set_challenge_responses(Some(challenge_responses))
.client_id("cognito client id".to_string())
.challenge_name(ChallengeNameType::PasswordVerifier)
.send()
.await;
let password_challenge_response = password_challenge_result.unwrap();
这里提供了一个与AWS SDK for rust集成的完整示例:https://github.com/lucdew/cognito-srp-auth
测试
仅手动测试,没有客户端密钥。
依赖项
~4.5–6.5MB
~117K SLoC