diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/cutils/abort_socket.h | 103 | ||||
| -rw-r--r-- | include/cutils/android_reboot.h | 5 | ||||
| -rw-r--r-- | include/cutils/array.h | 67 | ||||
| -rw-r--r-- | include/cutils/bitops.h | 10 | ||||
| -rw-r--r-- | include/cutils/mq.h | 124 | ||||
| -rw-r--r-- | include/cutils/properties.h | 24 | ||||
| -rw-r--r-- | include/cutils/qsort_r_compat.h | 39 | ||||
| -rw-r--r-- | include/cutils/selector.h | 130 | ||||
| -rw-r--r-- | include/cutils/trace.h | 5 | ||||
| -rw-r--r-- | include/cutils/zygote.h | 31 | ||||
| -rw-r--r-- | include/mincrypt/hash-internal.h | 40 | ||||
| -rw-r--r-- | include/mincrypt/rsa.h | 3 | ||||
| -rw-r--r-- | include/mincrypt/sha.h | 65 | ||||
| -rw-r--r-- | include/mincrypt/sha256.h | 29 | ||||
| -rw-r--r-- | include/private/android_filesystem_config.h | 2 |
15 files changed, 125 insertions, 552 deletions
diff --git a/include/cutils/abort_socket.h b/include/cutils/abort_socket.h deleted file mode 100644 index fbb1112..0000000 --- a/include/cutils/abort_socket.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2009, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Helper to perform abortable blocking operations on a socket: - * asocket_connect() - * asocket_accept() - * asocket_read() - * asocket_write() - * These calls are similar to the regular syscalls, but can be aborted with: - * asocket_abort() - * - * Calling close() on a regular POSIX socket does not abort blocked syscalls on - * that socket in other threads. - * - * After calling asocket_abort() the socket cannot be reused. - * - * Call asocket_destory() *after* all threads have finished with the socket to - * finish closing the socket and free the asocket structure. - * - * The helper is implemented by setting the socket non-blocking to initiate - * syscalls connect(), accept(), read(), write(), then using a blocking poll() - * on both the primary socket and a local pipe. This makes the poll() abortable - * by writing a byte to the local pipe in asocket_abort(). - * - * asocket_create() sets the fd to non-blocking mode. It must not be changed to - * blocking mode. - * - * Using asocket will triple the number of file descriptors required per - * socket, due to the local pipe. It may be possible to use a global pipe per - * process rather than per socket, but we have not been able to come up with a - * race-free implementation yet. - * - * All functions except asocket_init() and asocket_destroy() are thread safe. - */ - -#include <stdlib.h> -#include <sys/socket.h> - -#ifndef __CUTILS_ABORT_SOCKET_H__ -#define __CUTILS_ABORT_SOCKET_H__ -#ifdef __cplusplus -extern "C" { -#endif - -struct asocket { - int fd; /* primary socket fd */ - int abort_fd[2]; /* pipe used to abort */ -}; - -/* Create an asocket from fd. - * Sets the socket to non-blocking mode. - * Returns NULL on error with errno set. - */ -struct asocket *asocket_init(int fd); - -/* Blocking socket I/O with timeout. - * Calling asocket_abort() from another thread will cause each of these - * functions to immediately return with value -1 and errno ECANCELED. - * timeout is in ms, use -1 to indicate no timeout. On timeout -1 is returned - * with errno ETIMEDOUT. - * EINTR is handled in-call. - * Other semantics are identical to the regular syscalls. - */ -int asocket_connect(struct asocket *s, const struct sockaddr *addr, - socklen_t addrlen, int timeout); - -int asocket_accept(struct asocket *s, struct sockaddr *addr, - socklen_t *addrlen, int timeout); - -int asocket_read(struct asocket *s, void *buf, size_t count, int timeout); - -int asocket_write(struct asocket *s, const void *buf, size_t count, - int timeout); - -/* Abort above calls and shutdown socket. - * Further I/O operations on this socket will immediately fail after this call. - * asocket_destroy() should be used to release resources once all threads - * have returned from blocking calls on the socket. - */ -void asocket_abort(struct asocket *s); - -/* Close socket and free asocket structure. - * Must not be called until all calls on this structure have completed. - */ -void asocket_destroy(struct asocket *s); - -#ifdef __cplusplus -} -#endif -#endif //__CUTILS_ABORT_SOCKET__H__ diff --git a/include/cutils/android_reboot.h b/include/cutils/android_reboot.h index 0c79be7..8c30e8e 100644 --- a/include/cutils/android_reboot.h +++ b/include/cutils/android_reboot.h @@ -24,9 +24,8 @@ __BEGIN_DECLS #define ANDROID_RB_POWEROFF 0xDEAD0002 #define ANDROID_RB_RESTART2 0xDEAD0003 -/* Flags */ -#define ANDROID_RB_FLAG_NO_SYNC 0x1 -#define ANDROID_RB_FLAG_NO_REMOUNT_RO 0x2 +/* Properties */ +#define ANDROID_RB_PROPERTY "sys.powerctl" int android_reboot(int cmd, int flags, char *arg); diff --git a/include/cutils/array.h b/include/cutils/array.h deleted file mode 100644 index c97ff34..0000000 --- a/include/cutils/array.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * A pointer array which intelligently expands its capacity ad needed. - */ - -#ifndef __ARRAY_H -#define __ARRAY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdlib.h> - -/** An array. */ -typedef struct Array Array; - -/** Constructs a new array. Returns NULL if we ran out of memory. */ -Array* arrayCreate(); - -/** Frees an array. Does not free elements themselves. */ -void arrayFree(Array* array); - -/** Adds a pointer. Returns 0 is successful, < 0 otherwise. */ -int arrayAdd(Array* array, void* pointer); - -/** Gets the pointer at the specified index. */ -void* arrayGet(Array* array, int index); - -/** Removes the pointer at the given index and returns it. */ -void* arrayRemove(Array* array, int index); - -/** Sets pointer at the given index. Returns old pointer. */ -void* arraySet(Array* array, int index, void* pointer); - -/** Sets the array size. Sets new pointers to NULL. Returns 0 if successful, < 0 otherwise . */ -int arraySetSize(Array* array, int size); - -/** Returns the size of the given array. */ -int arraySize(Array* array); - -/** - * Returns a pointer to a C-style array which will be valid until this array - * changes. - */ -const void** arrayUnwrap(Array* array); - -#ifdef __cplusplus -} -#endif - -#endif /* __ARRAY_H */ diff --git a/include/cutils/bitops.h b/include/cutils/bitops.h index eb44236..c26dc54 100644 --- a/include/cutils/bitops.h +++ b/include/cutils/bitops.h @@ -75,6 +75,16 @@ static inline int bitmask_ffz(unsigned int *bitmask, int num_bits) return -1; } +static inline int bitmask_weight(unsigned int *bitmask, int num_bits) +{ + int i; + int weight = 0; + + for (i = 0; i < BITS_TO_WORDS(num_bits); i++) + weight += __builtin_popcount(bitmask[i]); + return weight; +} + static inline void bitmask_set(unsigned int *bitmask, int bit) { bitmask[BIT_WORD(bit)] |= BIT_MASK(bit); diff --git a/include/cutils/mq.h b/include/cutils/mq.h deleted file mode 100644 index b27456d..0000000 --- a/include/cutils/mq.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * IPC messaging library. - */ - -#ifndef __MQ_H -#define __MQ_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** A message. */ -typedef struct MqMessage MqMessage; - -/** A destination to which messages can be sent. */ -typedef struct MqDestination MqDestination; - -/* Array of bytes. */ -typedef struct MqBytes MqBytes; - -/** - * Hears messages. - * - * @param destination to which the message was sent - * @param message the message to hear - */ -typedef void MqMessageListener(MqDestination* destination, MqMessage* message); - -/** - * Hears a destination close. - * - * @param destination that closed - */ -typedef void MqCloseListener(MqDestination* destination); - -/** Message functions. */ - -/** - * Creates a new Message. - * - * @param header as defined by user - * @param body as defined by user - * @param replyTo destination to which replies should be sent, NULL if none - */ -MqMessage* mqCreateMessage(MqBytes header, MqBytes body, - MqDestination* replyTo); - -/** Sends a message to a destination. */ -void mqSendMessage(MqMessage* message, MqDestination* destination); - -/** Destination functions. */ - -/** - * Creates a new destination. Acquires a reference implicitly. - * - * @param messageListener function to call when a message is recieved - * @param closeListener function to call when the destination closes - * @param userData user-specific data to associate with the destination. - * Retrieve using mqGetDestinationUserData(). - */ -MqDestination* mqCreateDestination(MqMessageListener* messageListener, - MqCloseListener* closeListener, void* userData); - -/** - * Gets user data which was associated with the given destination at - * construction time. - * - * It is only valid to call this function in the same process that the - * given destination was created in. - * This function returns a null pointer if you call it on a destination - * created in a remote process. - */ -void* mqGetUserData(MqDestination* destination); - -/** - * Returns 1 if the destination was created in this process, or 0 if - * the destination was created in a different process, in which case you have - * a remote stub. - */ -int mqIsDestinationLocal(MqDestination* destination); - -/** - * Increments the destination's reference count. - */ -void mqKeepDestination(MqDesintation* destination); - -/** - * Decrements the destination's reference count. - */ -void mqFreeDestination(MqDestination* desintation); - -/** Registry API. */ - -/** - * Gets the destination bound to a name. - */ -MqDestination* mqGetDestination(char* name); - -/** - * Binds a destination to a name. - */ -void mqPutDestination(char* name, MqDestination* desintation); - -#ifdef __cplusplus -} -#endif - -#endif /* __MQ_H */ diff --git a/include/cutils/properties.h b/include/cutils/properties.h index 25fd67a..2c70165 100644 --- a/include/cutils/properties.h +++ b/include/cutils/properties.h @@ -17,6 +17,10 @@ #ifndef __CUTILS_PROPERTIES_H #define __CUTILS_PROPERTIES_H +#include <sys/cdefs.h> +#include <stddef.h> +#include <sys/system_properties.h> + #ifdef __cplusplus extern "C" { #endif @@ -28,8 +32,8 @@ extern "C" { ** WARNING: system/bionic/include/sys/system_properties.h also defines ** these, but with different names. (TODO: fix that) */ -#define PROPERTY_KEY_MAX 32 -#define PROPERTY_VALUE_MAX 92 +#define PROPERTY_KEY_MAX PROP_NAME_MAX +#define PROPERTY_VALUE_MAX PROP_VALUE_MAX /* property_get: returns the length of the value which will never be ** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated. @@ -46,6 +50,22 @@ int property_set(const char *key, const char *value); int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie); +#if defined(__BIONIC_FORTIFY) + +extern int __property_get_real(const char *, char *, const char *) + __asm__(__USER_LABEL_PREFIX__ "property_get"); +__errordecl(__property_get_too_small_error, "property_get() called with too small of a buffer"); + +__BIONIC_FORTIFY_INLINE +int property_get(const char *key, char *value, const char *default_value) { + size_t bos = __bos(value); + if (bos < PROPERTY_VALUE_MAX) { + __property_get_too_small_error(); + } + return __property_get_real(key, value, default_value); +} + +#endif #ifdef HAVE_SYSTEM_PROPERTY_SERVER /* diff --git a/include/cutils/qsort_r_compat.h b/include/cutils/qsort_r_compat.h deleted file mode 100644 index 479a1ab..0000000 --- a/include/cutils/qsort_r_compat.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Provides a portable version of qsort_r, called qsort_r_compat, which is a - * reentrant variant of qsort that passes a user data pointer to its comparator. - * This implementation follows the BSD parameter convention. - */ - -#ifndef _LIBS_CUTILS_QSORT_R_COMPAT_H -#define _LIBS_CUTILS_QSORT_R_COMPAT_H - -#include <stdlib.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk, - int (*compar)(void*, const void* , const void* )); - -#ifdef __cplusplus -} -#endif - -#endif // _LIBS_CUTILS_QSORT_R_COMPAT_H diff --git a/include/cutils/selector.h b/include/cutils/selector.h deleted file mode 100644 index dfc2a9d..0000000 --- a/include/cutils/selector.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Framework for multiplexing I/O. A selector manages a set of file - * descriptors and calls out to user-provided callback functions to read and - * write data and handle errors. - */ - -#ifndef __SELECTOR_H -#define __SELECTOR_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdbool.h> - -/** - * Manages SelectableFds and invokes their callbacks at appropriate times. - */ -typedef struct Selector Selector; - -/** - * A selectable descriptor. Contains callbacks which the selector can invoke - * before calling select(), when the descriptor is readable or writable, and - * when the descriptor contains out-of-band data. Simply set a callback to - * NULL if you're not interested in that particular event. - * - * A selectable descriptor can indicate that it needs to be removed from the - * selector by setting the 'remove' flag. The selector will remove the - * descriptor at a later time and invoke the onRemove() callback. - * - * SelectableFd fields should only be modified from the selector loop. - */ -typedef struct SelectableFd SelectableFd; -struct SelectableFd { - - /** The file descriptor itself. */ - int fd; - - /** Pointer to user-specific data. Can be NULL. */ - void* data; - - /** - * Set this flag when you no longer wish to be selected. The selector - * will invoke onRemove() when the descriptor is actually removed. - */ - bool remove; - - /** - * Invoked by the selector before calling select. You can set up other - * callbacks from here as necessary. - */ - void (*beforeSelect)(SelectableFd* self); - - /** - * Invoked by the selector when the descriptor has data available. Set to - * NULL to indicate that you're not interested in reading. - */ - void (*onReadable)(SelectableFd* self); - - /** - * Invoked by the selector when the descriptor can accept data. Set to - * NULL to indicate that you're not interested in writing. - */ - void (*onWritable)(SelectableFd* self); - - /** - * Invoked by the selector when out-of-band (OOB) data is available. Set to - * NULL to indicate that you're not interested in OOB data. - */ - void (*onExcept)(SelectableFd* self); - - /** - * Invoked by the selector after the descriptor is removed from the - * selector but before the selector frees the SelectableFd memory. - */ - void (*onRemove)(SelectableFd* self); - - /** - * The selector which selected this fd. Set by the selector itself. - */ - Selector* selector; -}; - -/** - * Creates a new selector. - */ -Selector* selectorCreate(void); - -/** - * Creates a new selectable fd, adds it to the given selector and returns a - * pointer. Outside of 'selector' and 'fd', all fields are set to 0 or NULL - * by default. - * - * The selectable fd should only be modified from the selector loop thread. - */ -SelectableFd* selectorAdd(Selector* selector, int fd); - -/** - * Wakes up the selector even though no I/O events occurred. Use this - * to indicate that you're ready to write to a descriptor. - */ -void selectorWakeUp(Selector* selector); - -/** - * Loops continuously selecting file descriptors and firing events. - * Does not return. - */ -void selectorLoop(Selector* selector); - -#ifdef __cplusplus -} -#endif - -#endif /* __SELECTOR_H */ diff --git a/include/cutils/trace.h b/include/cutils/trace.h index 29034ca..a0dd1e0 100644 --- a/include/cutils/trace.h +++ b/include/cutils/trace.h @@ -66,7 +66,8 @@ __BEGIN_DECLS #define ATRACE_TAG_APP (1<<12) #define ATRACE_TAG_RESOURCES (1<<13) #define ATRACE_TAG_DALVIK (1<<14) -#define ATRACE_TAG_LAST ATRACE_TAG_DALVIK +#define ATRACE_TAG_RS (1<<15) +#define ATRACE_TAG_LAST ATRACE_TAG_RS // Reserved for initialization. #define ATRACE_TAG_NOT_READY (1LL<<63) @@ -262,7 +263,7 @@ static inline void atrace_int(uint64_t tag, const char* name, int32_t value) #define ATRACE_INIT() #define ATRACE_GET_ENABLED_TAGS() -#define ATRACE_ENABLED() +#define ATRACE_ENABLED() 0 #define ATRACE_BEGIN(name) #define ATRACE_END() #define ATRACE_ASYNC_BEGIN(name, cookie) diff --git a/include/cutils/zygote.h b/include/cutils/zygote.h deleted file mode 100644 index a7480d3..0000000 --- a/include/cutils/zygote.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __CUTILS_ZYGOTE_H -#define __CUTILS_ZYGOTE_H - -#ifdef __cplusplus -extern "C" { -#endif - -int zygote_run_oneshot(int sendStdio, int argc, const char **argv); -int zygote_run(int argc, const char **argv); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_ZYGOTE_H */ diff --git a/include/mincrypt/hash-internal.h b/include/mincrypt/hash-internal.h new file mode 100644 index 0000000..96806f7 --- /dev/null +++ b/include/mincrypt/hash-internal.h @@ -0,0 +1,40 @@ +// Copyright 2007 Google Inc. All Rights Reserved. +// Author: mschilder@google.com (Marius Schilder) + +#ifndef SECURITY_UTIL_LITE_HASH_INTERNAL_H__ +#define SECURITY_UTIL_LITE_HASH_INTERNAL_H__ + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +struct HASH_CTX; // forward decl + +typedef struct HASH_VTAB { + void (* const init)(struct HASH_CTX*); + void (* const update)(struct HASH_CTX*, const void*, int); + const uint8_t* (* const final)(struct HASH_CTX*); + const uint8_t* (* const hash)(const void*, int, uint8_t*); + int size; +} HASH_VTAB; + +typedef struct HASH_CTX { + const HASH_VTAB * f; + uint64_t count; + uint8_t buf[64]; + uint32_t state[8]; // upto SHA2 +} HASH_CTX; + +#define HASH_init(ctx) (ctx)->f->init(ctx) +#define HASH_update(ctx, data, len) (ctx)->f->update(ctx, data, len) +#define HASH_final(ctx) (ctx)->f->final(ctx) +#define HASH_hash(data, len, digest) (ctx)->f->hash(data, len, digest) +#define HASH_size(ctx) (ctx)->f->size + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // SECURITY_UTIL_LITE_HASH_INTERNAL_H__ diff --git a/include/mincrypt/rsa.h b/include/mincrypt/rsa.h index d7429fc..cc0e800 100644 --- a/include/mincrypt/rsa.h +++ b/include/mincrypt/rsa.h @@ -48,7 +48,8 @@ typedef struct RSAPublicKey { int RSA_verify(const RSAPublicKey *key, const uint8_t* signature, const int len, - const uint8_t* sha); + const uint8_t* hash, + const int hash_len); #ifdef __cplusplus } diff --git a/include/mincrypt/sha.h b/include/mincrypt/sha.h index af63e87..120ddcb 100644 --- a/include/mincrypt/sha.h +++ b/include/mincrypt/sha.h @@ -1,63 +1,30 @@ -/* sha.h -** -** Copyright 2008, The Android Open Source Project -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of Google Inc. nor the names of its contributors may -** be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -** EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef _EMBEDDED_SHA_H_ -#define _EMBEDDED_SHA_H_ - -#include <inttypes.h> +// Copyright 2005 Google Inc. All Rights Reserved. +// Author: mschilder@google.com (Marius Schilder) + +#ifndef SECURITY_UTIL_LITE_SHA1_H__ +#define SECURITY_UTIL_LITE_SHA1_H__ + +#include <stdint.h> +#include "hash-internal.h" #ifdef __cplusplus extern "C" { -#endif - -typedef struct SHA_CTX { - uint64_t count; - uint32_t state[5]; -#if defined(HAVE_ENDIAN_H) && defined(HAVE_LITTLE_ENDIAN) - union { - uint8_t b[64]; - uint32_t w[16]; - } buf; -#else - uint8_t buf[64]; -#endif -} SHA_CTX; +#endif // __cplusplus + +typedef HASH_CTX SHA_CTX; void SHA_init(SHA_CTX* ctx); void SHA_update(SHA_CTX* ctx, const void* data, int len); const uint8_t* SHA_final(SHA_CTX* ctx); -/* Convenience method. Returns digest parameter value. */ -const uint8_t* SHA(const void* data, int len, uint8_t* digest); +// Convenience method. Returns digest address. +// NOTE: *digest needs to hold SHA_DIGEST_SIZE bytes. +const uint8_t* SHA_hash(const void* data, int len, uint8_t* digest); #define SHA_DIGEST_SIZE 20 #ifdef __cplusplus } -#endif +#endif // __cplusplus -#endif +#endif // SECURITY_UTIL_LITE_SHA1_H__ diff --git a/include/mincrypt/sha256.h b/include/mincrypt/sha256.h new file mode 100644 index 0000000..0f3efb7 --- /dev/null +++ b/include/mincrypt/sha256.h @@ -0,0 +1,29 @@ +// Copyright 2011 Google Inc. All Rights Reserved. +// Author: mschilder@google.com (Marius Schilder) + +#ifndef SECURITY_UTIL_LITE_SHA256_H__ +#define SECURITY_UTIL_LITE_SHA256_H__ + +#include <stdint.h> +#include "hash-internal.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +typedef HASH_CTX SHA256_CTX; + +void SHA256_init(SHA256_CTX* ctx); +void SHA256_update(SHA256_CTX* ctx, const void* data, int len); +const uint8_t* SHA256_final(SHA256_CTX* ctx); + +// Convenience method. Returns digest address. +const uint8_t* SHA256_hash(const void* data, int len, uint8_t* digest); + +#define SHA256_DIGEST_SIZE 32 + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // SECURITY_UTIL_LITE_SHA256_H__ diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h index 5d363a7..4a7d377 100644 --- a/include/private/android_filesystem_config.h +++ b/include/private/android_filesystem_config.h @@ -229,7 +229,7 @@ static const struct fs_path_config android_files[] = { { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/tcpdump" }, { 04770, AID_ROOT, AID_RADIO, 0, "system/bin/pppd-ril" }, - /* the following file has enhanced capabilities and IS included in user builds. */ + /* the following files have enhanced capabilities and ARE included in user builds. */ { 00750, AID_ROOT, AID_SHELL, (1 << CAP_SETUID) | (1 << CAP_SETGID), "system/bin/run-as" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" }, |
