]> git.saurik.com Git - apple/xnu.git/blob - osfmk/corecrypto/cc/src/cc_clear.c
79f9d971f74237a54ee03ffac66207164de0fc3a
[apple/xnu.git] / osfmk / corecrypto / cc / src / cc_clear.c
1 /*
2 * cc_clear.c
3 * corecrypto
4 *
5 * Created on 05/21/2014
6 *
7 * Copyright (c) 2014,2015 Apple Inc. All rights reserved.
8 *
9 */
10
11 #include <corecrypto/cc.h>
12
13 void cc_clear(size_t len, void *dst)
14 {
15 #if ( CC_HAS_MEMSET_S == 1 ) && (defined( __STDC_WANT_LIB_EXT1__ ) && ( __STDC_WANT_LIB_EXT1__ == 1 ) )
16 memset_s(dst,len,0,len);
17 #else
18 volatile size_t ctr=0;
19 volatile uint8_t *data=dst;
20 if (len) {
21 cc_zero(len,dst);
22 (void)data[ctr]; // Touch the buffer so that the compiler does not
23 // Optimize out the zeroing
24 }
25 #endif
26 }
27