* Check semantics of a digest credentials structure * Make sure that all attributes needed to verify response * string are set or at least have a default value * * The returned value is logical OR of all errors encountered * during the check, see dig_err_t type for more details */
| 104 | * during the check, see dig_err_t type for more details |
| 105 | */ |
| 106 | dig_err_t check_dig_cred(dig_cred_t* _c) |
| 107 | { |
| 108 | dig_err_t res = E_DIG_OK; |
| 109 | |
| 110 | /* Username must be present */ |
| 111 | if (_c->username.user.s == 0) res |= E_DIG_USERNAME; |
| 112 | |
| 113 | /* Realm must be present */ |
| 114 | if (_c->realm.s == 0) res |= E_DIG_REALM; |
| 115 | |
| 116 | /* Nonce that was used must be specified */ |
| 117 | if (_c->nonce.s == 0) res |= E_DIG_NONCE; |
| 118 | |
| 119 | /* URI must be specified */ |
| 120 | if (_c->uri.s == 0) res |= E_DIG_URI; |
| 121 | |
| 122 | /* We cannot check credentials without response */ |
| 123 | if (_c->response.s == 0) res |= E_DIG_RESPONSE; |
| 124 | |
| 125 | /* If QOP parameter is present, some additional |
| 126 | * requirements must be met |
| 127 | */ |
| 128 | if (_c->qop.qop_parsed != QOP_UNSPEC_D) { |
| 129 | /* CNONCE must be specified */ |
| 130 | if (_c->cnonce.s == 0) res |= E_DIG_CNONCE; |
| 131 | /* and also nonce count must be specified */ |
| 132 | if (_c->nc.s == 0) res |= E_DIG_NC; |
| 133 | } |
| 134 | |
| 135 | return res; |
| 136 | } |
| 137 | |
| 138 | |
| 139 | /* |
no outgoing calls
no test coverage detected