# Source code for the SHA512_End function.



## Oleg P. (Dec 23, 2019)

Hello!
Dear Developers I need a little help or advice.
Where (or how) can I find source code for the function SHA512_End in the /usr/src directory?
I need it to write a test for the 32bit implementation OpenSSL, which I began to write (https://github.com/FreeBSD-pzn/openssl_vax).


----------



## mark_j (Dec 25, 2019)

As per the man page, it says it's in libmd: https://www.freebsd.org/cgi/man.cgi...th=FreeBSD+9-current&arch=default&format=html

A further search on github of freebsd:








						Search · sha512_end · freebsd/freebsd-src
					

FreeBSD src tree (read-only mirror). Contribute to freebsd/freebsd-src development by creating an account on GitHub.




					github.com
				




Specifically it's in:
freebsd/crypto/openssh/openbsd-compatsha2.h


----------



## Phishfry (Dec 25, 2019)

Oleg P. said:


> Where (or how) can I find source code for the function SHA512_End in the /usr/src directory?


The source files on your computer:
/usr/src/sys/crypto/sha2/


----------



## Phishfry (Dec 25, 2019)

Here is the header for it:
/usr/src/sys/crypto/sha2/sha512.h

```
#ifndef SHA512_End
#define SHA512_End        _libmd_SHA512_End
#endif
```

Something related I ran across when searching:




__





						⚙ D3929 Replace sys/crypto/sha2/sha2.c with lib/libmd/sha512c.c
					






					reviews.freebsd.org


----------



## Phishfry (Dec 25, 2019)

Here is a command to search inside all the source files for your string.
`grep "SHA512_End" -rns /usr/src/`


----------



## Oleg P. (Dec 25, 2019)

Hi!
I was trying all queries and I couldn't find source code.
The source code for the functions SHA.._End, SHA..._Data and SHA.._File are in the __attribute__(_bounded(...)), but where are all that functions?
For example: the source code for the sha512 executable file is in the md5.c.


----------



## mark_j (Dec 25, 2019)

I'm not sure I understand?





```
char *SHA256_End(SHA256_CTX *, char *)
__attribute__((__bounded__(__minbytes__,2,SHA256_DIGEST_STRING_LENGTH)));
```


This says take parameter 2 (char * - the buffer and return the SHA256_DIGEST_STRING_LENGTH (which is 129 according to the manual page):


*SHA512*_*End*() is a wrapper for *SHA512*_*Final*() which    converts the return
     value to a    129-character (including the terminating '\0') ASCII string
     which represents the 512 bits in hexadecimal.

All the relevant functions are in sha512.c such as SHA512_Update, Sha512_Final, SHA512_Init etc.
An example of it being used:

```
return (SHA512_End(&(c->SHA512), buf));
```

(Then again it's Christmas and I may have had a few beverages...)


----------



## Oleg P. (Dec 27, 2019)

Hi!
I am trying to find bodies of functions SHA512_End(), SHA512_Data() and SHA512_File().
For instance: bodies of functions SHA512_Init(), SHA512_Update ... are in the sha512.c file, but
this file does not include bodies of functions SHA512_End(), SHA512_Data() and SHA512_File().


----------



## shkhln (Dec 27, 2019)

Oleg P. said:


> I need a little help or advice.



The advice is: _stop wasting your time._



Oleg P. said:


> 32bit implementation OpenSSL, which I began to write (https://github.com/FreeBSD-pzn/openssl_vax).



What makes you think OpenSSL only works with 64-bit platforms?


----------



## shkhln (Dec 27, 2019)

Ah, so this is about OpenVMS, VAX and compiler support for long long / int64_t. That's completely off-topic here.


----------



## SirDice (Dec 27, 2019)

Issue has nothing to do with FreeBSD. Thread closed.

Rule #7: FreeBSD Forums Rules


----------

