Bug 1943761 - Add class alignment to the mozsearch analysis file. r=asuth
[gecko.git] / security / manager / ssl / crypto_hash / crypto_hash.h
bloba85993b04165ec252bdb1aeeec3e9110491fd604
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"
7 extern "C" {
8 nsresult crypto_hash_constructor(REFNSIID iid, void** result);
9 };
11 nsresult NS_NewCryptoHash(uint32_t aHashType, nsICryptoHash** aOutHasher) {
12 MOZ_ASSERT(aOutHasher);
14 nsCOMPtr<nsICryptoHash> hasher;
15 nsresult rv =
16 crypto_hash_constructor(NS_ICRYPTOHASH_IID, getter_AddRefs(hasher));
17 if (NS_FAILED(rv)) {
18 return rv;
20 rv = hasher->Init(aHashType);
21 if (NS_FAILED(rv)) {
22 return rv;
24 hasher.forget(aOutHasher);
26 return NS_OK;
29 nsresult NS_NewCryptoHash(const nsACString& aHashType,
30 nsICryptoHash** aOutHasher) {
31 MOZ_ASSERT(aOutHasher);
33 nsCOMPtr<nsICryptoHash> hasher;
34 nsresult rv =
35 crypto_hash_constructor(NS_ICRYPTOHASH_IID, getter_AddRefs(hasher));
36 if (NS_FAILED(rv)) {
37 return rv;
39 rv = hasher->InitWithString(aHashType);
40 if (NS_FAILED(rv)) {
41 return rv;
43 hasher.forget(aOutHasher);
45 return NS_OK;