简体   繁体   English

OMA DM1.2 md5摘要计算

[英]OMA DM1.2 md5 digest calculation

I am implementing a server for communication using the OMA DM 1.2 SyncML protocol and reffers to the OMA Device Management Security document. 我正在使用OMA DM 1.2 SyncML协议实现用于通信的服务器,并且参考OMA设备管理安全性文档。 I am having issues with authentication. 我的认证有问题。 The client sends a challenge to the server as: 客户端向服务器发送质询:

<Chal>
    <Meta>
        <Format xmlns="syncml:metinf">b64</Format>
        <Type xmlns="syncml:metinf">syncml:auth-md5</Type>
        <NextNonce xmlns="syncml:metinf">RLLe7tWM313qHMq9ooUZUPJX0RqU9mEZuyoVF+jXhqQ=</NextNonce>
    </Meta>
</Chal>

I then calculate the md5-digest to return to the device using the java code, where nonce is the Base64 string in "NextNonce" in challenge above: 然后,我使用java代码计算md5-digest返回到设备,其中nonce是上述挑战中“ NextNonce”中的Base64字符串:

MessageDigest digest = MessageDigest.getInstance("MD5");
String usrPwd = username + ":" + password;
String usrPwdHash = Base64.encodeBase64String(digest.digest(usrPwd.getBytes("utf-8")));
String usrPwdNonce = usrPwdHash + ":" + nonce;
String usrPwdNonceHash = Base64.encodeBase64String(digest.digest(usrPwdNonce.getBytes("utf-8")));
return usrPwdNonceHash;

Then this hash is returned to the device as: 然后,此哈希将以以下形式返回给设备:

<Cred>
        <Meta>
              <ns2:Type>syncml:auth-md5</ns2:Type>
              <ns2:Format>b64</ns2:Format>
        </Meta>
        <Data>QpbMtvvfNGRIavJ0jqcxaw==</Data>
</Cred>

But the device returns with a status 401 and a new challenge. 但是设备返回状态401和新的质询。 Is there something wrong with how i calculate the md5-hash or must there be some other issue? 我如何计算md5-hash是否有问题,还是必须存在其他问题?

Found my error. 发现我的错误。 The nonce should be the decoded Base64 string value, not the Base64 string. 随机数应该是解码的Base64字符串值,而不是Base64字符串。

nonce = new String(Base64.decodeBase64("RLLe7tWM313qHMq9ooUZUPJX0RqU9mEZuyoVF+jXhqQ="), "utf-8");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM