1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsICryptoHash.h"
8 nsresult
crypto_hash_constructor(REFNSIID iid
, void** result
);
11 nsresult
NS_NewCryptoHash(uint32_t aHashType
, nsICryptoHash
** aOutHasher
) {
12 MOZ_ASSERT(aOutHasher
);
14 nsCOMPtr
<nsICryptoHash
> hasher
;
16 crypto_hash_constructor(NS_ICRYPTOHASH_IID
, getter_AddRefs(hasher
));
20 rv
= hasher
->Init(aHashType
);
24 hasher
.forget(aOutHasher
);
29 nsresult
NS_NewCryptoHash(const nsACString
& aHashType
,
30 nsICryptoHash
** aOutHasher
) {
31 MOZ_ASSERT(aOutHasher
);
33 nsCOMPtr
<nsICryptoHash
> hasher
;
35 crypto_hash_constructor(NS_ICRYPTOHASH_IID
, getter_AddRefs(hasher
));
39 rv
= hasher
->InitWithString(aHashType
);
43 hasher
.forget(aOutHasher
);