ripemd.h (2349B)
1 // Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef OPENSSL_HEADER_RIPEMD_H 16 #define OPENSSL_HEADER_RIPEMD_H 17 18 #include <openssl/base.h> // IWYU pragma: export 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 25 # define RIPEMD160_CBLOCK 64 26 # define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) 27 # define RIPEMD160_DIGEST_LENGTH 20 28 29 struct RIPEMD160state_st { 30 uint32_t h[5]; 31 uint32_t Nl, Nh; 32 uint8_t data[RIPEMD160_CBLOCK]; 33 unsigned num; 34 }; 35 36 // RIPEMD160_Init initialises |ctx| and returns one. 37 OPENSSL_EXPORT int RIPEMD160_Init(RIPEMD160_CTX *ctx); 38 39 // RIPEMD160_Update adds |len| bytes from |data| to |ctx| and returns one. 40 OPENSSL_EXPORT int RIPEMD160_Update(RIPEMD160_CTX *ctx, const void *data, 41 size_t len); 42 43 // RIPEMD160_Final adds the final padding to |ctx| and writes the resulting 44 // digest to |out|, which must have at least |RIPEMD160_DIGEST_LENGTH| bytes of 45 // space. It returns one. 46 OPENSSL_EXPORT int RIPEMD160_Final(uint8_t out[RIPEMD160_DIGEST_LENGTH], 47 RIPEMD160_CTX *ctx); 48 49 // RIPEMD160 writes the digest of |len| bytes from |data| to |out| and returns 50 // |out|. There must be at least |RIPEMD160_DIGEST_LENGTH| bytes of space in 51 // |out|. 52 OPENSSL_EXPORT uint8_t *RIPEMD160(const uint8_t *data, size_t len, 53 uint8_t out[RIPEMD160_DIGEST_LENGTH]); 54 55 // RIPEMD160_Transform is a low-level function that performs a single, 56 // RIPEMD160 block transformation using the state from |ctx| and 64 bytes from 57 // |block|. 58 OPENSSL_EXPORT void RIPEMD160_Transform(RIPEMD160_CTX *ctx, 59 const uint8_t block[RIPEMD160_CBLOCK]); 60 61 62 #if defined(__cplusplus) 63 } // extern C 64 #endif 65 66 #endif // OPENSSL_HEADER_RIPEMD_H